@@ -26,7 +26,7 @@ import {
26
26
import { IndexHtmlWebpackPlugin } from '@angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin' ;
27
27
import { getSystemPath , logging , normalize , tags } from '@angular-devkit/core' ;
28
28
import { NodeJsSyncHost } from '@angular-devkit/core/node' ;
29
- import { AngularWebpack , WebpackSetup } from '@teambit/angular' ;
29
+ import { AngularWebpack , optionValue , WebpackSetup } from '@teambit/angular' ;
30
30
import { BundlerContext , DevServerContext } from '@teambit/bundler' ;
31
31
import { CompositionsMain } from '@teambit/compositions' ;
32
32
import { Logger } from '@teambit/logger' ;
@@ -67,66 +67,11 @@ export class AngularV10Webpack extends AngularWebpack {
67
67
* Migrate options from webpack-dev-server 3 to 4
68
68
*/
69
69
private migrateConfiguration ( webpackConfig : Configuration ) : Configuration {
70
- // /**
71
- // * Removed logLevel in favor of built-in logger
72
- // * see https://webpack.js.org/configuration/other-options/#infrastructurelogginglevel
73
- // */
74
- // // @ts -ignore
75
- // delete webpackConfig.devServer.logLevel;
76
- //
77
70
/**
78
71
* Removed contentBase in favor of the static option
79
72
*/
80
73
// @ts -ignore
81
74
delete webpackConfig . devServer . contentBase ;
82
- //
83
- // /**
84
- // * Removed publicPath in favor of the dev option
85
- // */
86
- // // @ts -ignore
87
- // delete webpackConfig.devServer.publicPath;
88
- //
89
- // /**
90
- // * Moved overlay to client option
91
- // */
92
- // // @ts -ignore
93
- // webpackConfig.devServer.client = webpackConfig.devServer.client || {};
94
- // // @ts -ignore
95
- // webpackConfig.devServer.client.overlay = webpackConfig.devServer.overlay;
96
- // // @ts -ignore
97
- // delete webpackConfig.devServer.overlay;
98
- //
99
- // /**
100
- // * Removed in favor of the static option
101
- // */
102
- // // @ts -ignore
103
- // delete webpackConfig.devServer.watchOptions;
104
- //
105
- // /**
106
- // * Moved sockPath to client option path
107
- // */
108
- // // @ts -ignore
109
- // webpackConfig.devServer.client.path = webpackConfig.devServer.sockPath;
110
- // // @ts -ignore
111
- // delete webpackConfig.devServer.sockPath;
112
- //
113
- // /**
114
- // * Removed stats in favor of the stats options from webpack
115
- // */
116
- // // @ts -ignore
117
- // delete webpackConfig.devServer.stats;
118
- //
119
- // /**
120
- // * Cleaning up undefined values
121
- // */
122
- // // @ts -ignore
123
- // Object.keys(webpackConfig.devServer).forEach(option => {
124
- // // @ts -ignore
125
- // if (typeof webpackConfig.devServer[option] === 'undefined') {
126
- // // @ts -ignore
127
- // delete webpackConfig.devServer[option];
128
- // }
129
- // })
130
75
131
76
return webpackConfig ;
132
77
}
@@ -138,34 +83,32 @@ export class AngularV10Webpack extends AngularWebpack {
138
83
workspaceRoot : string ,
139
84
logger : Logger ,
140
85
setup : WebpackSetup ,
141
- extraOptions : Partial < WebpackConfigWithDevServer > = { }
86
+ webpackOptions : Partial < WebpackConfigWithDevServer > = { } ,
87
+ angularOptions : Partial < BrowserBuilderSchema > = { }
142
88
) : Promise < WebpackConfigWithDevServer | Configuration > {
143
89
// Options from angular.json
144
90
const browserOptions : BrowserBuilderSchema = {
91
+ ...angularOptions ,
145
92
baseHref : path . posix . join ( '/' , context . rootPath ! , context . publicPath ! ) ,
146
93
preserveSymlinks : true ,
147
94
outputPath : 'public' , // doesn't matter because it will be deleted from the config
148
95
index : 'src/index.html' ,
149
96
main : 'src/main.ts' ,
150
97
polyfills : 'src/polyfills.ts' ,
151
98
tsConfig : tsconfigPath ,
152
- assets : [ 'src/favicon.ico' , 'src/assets' ] ,
153
- styles : [ 'src/styles.scss' ] ,
154
- scripts : [ ] ,
155
- vendorChunk : true ,
156
- namedChunks : true ,
157
- optimization : setup === WebpackSetup . Build ,
158
- buildOptimizer : setup === WebpackSetup . Build ,
159
- aot : true ,
160
- deleteOutputPath : true ,
161
- sourceMap : setup === WebpackSetup . Serve ,
162
- outputHashing : setup === WebpackSetup . Build ? OutputHashing . All : OutputHashing . None ,
163
- // inlineStyleLanguage: InlineStyleLanguage.Scss,
99
+ assets : [ 'src/favicon.ico' , 'src/assets' , ...( angularOptions . assets || [ ] ) ] ,
100
+ styles : [ 'src/styles.scss' , ...( angularOptions . styles || [ ] ) ] ,
101
+ scripts : angularOptions . scripts ,
102
+ vendorChunk : optionValue ( angularOptions . vendorChunk , true ) ,
103
+ namedChunks : optionValue ( angularOptions . namedChunks , true ) ,
104
+ optimization : optionValue ( angularOptions . optimization , setup === WebpackSetup . Build ) ,
105
+ buildOptimizer : optionValue ( angularOptions . buildOptimizer , setup === WebpackSetup . Build ) ,
106
+ aot : optionValue ( angularOptions . aot , true ) ,
107
+ deleteOutputPath : optionValue ( angularOptions . deleteOutputPath , true ) ,
108
+ sourceMap : optionValue ( angularOptions . sourceMap , setup === WebpackSetup . Serve ) ,
109
+ outputHashing : optionValue ( angularOptions . outputHashing , setup === WebpackSetup . Build ? OutputHashing . All : OutputHashing . None ) ,
164
110
watch : setup === WebpackSetup . Serve ,
165
- allowedCommonJsDependencies : [ '@teambit/harmony' , 'graphql' ] ,
166
- // deployUrl: undefined,
167
- // subresourceIntegrity: undefined,
168
- // crossOrigin: undefined,
111
+ allowedCommonJsDependencies : [ '@teambit/harmony' , 'graphql' , ...( angularOptions . allowedCommonJsDependencies || [ ] ) ] ,
169
112
} ;
170
113
171
114
const normalizedWorkspaceRoot = normalize ( workspaceRoot ) ;
@@ -175,7 +118,7 @@ export class AngularV10Webpack extends AngularWebpack {
175
118
const host = new NodeJsSyncHost ( ) ;
176
119
const normalizedOptions = normalizeBrowserSchema ( host , normalizedWorkspaceRoot , projectRoot , sourceRoot , {
177
120
...browserOptions ,
178
- ...( extraOptions as Partial < BrowserBuilderSchema & DevServerBuilderOptions > ) ,
121
+ ...( webpackOptions as Partial < BrowserBuilderSchema & DevServerBuilderOptions > ) ,
179
122
} ) ;
180
123
181
124
const loggerApi = {
@@ -205,7 +148,7 @@ export class AngularV10Webpack extends AngularWebpack {
205
148
if ( setup === WebpackSetup . Serve ) {
206
149
webpackConfig . devServer = buildServerConfig (
207
150
normalizedWorkspaceRoot ,
208
- extraOptions as DevServerBuilderOptions ,
151
+ webpackOptions as DevServerBuilderOptions ,
209
152
browserOptions ,
210
153
loggerApi
211
154
) ;
@@ -215,7 +158,7 @@ export class AngularV10Webpack extends AngularWebpack {
215
158
webpackConfig . entry . main . unshift ( ...entryFiles ) ;
216
159
217
160
// @ts -ignore
218
- if ( extraOptions . liveReload && ! extraOptions . hmr ) {
161
+ if ( webpackOptions . liveReload && ! webpackOptions . hmr ) {
219
162
// This is needed because we cannot use the inline option directly in the config
220
163
// because of the SuppressExtractedTextChunksWebpackPlugin
221
164
// Consider not using SuppressExtractedTextChunksWebpackPlugin when liveReload is enable.
@@ -250,7 +193,7 @@ export class AngularV10Webpack extends AngularWebpack {
250
193
}
251
194
252
195
// @ts -ignore
253
- if ( extraOptions . hmr ) {
196
+ if ( webpackOptions . hmr ) {
254
197
logger . warn ( tags . stripIndents `NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.
255
198
See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.` ) ;
256
199
}
0 commit comments