Skip to content

Commit c7d3d3b

Browse files
committed
Do not add the lazy routes to the entry points.
1 parent 789f4ef commit c7d3d3b

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

addon/ng2/models/webpack-build-common.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ import {findLazyModules} from './find-lazy-modules';
99

1010
export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
1111
const sourceRoot = path.resolve(projectRoot, `./${sourceDir}`);
12-
1312
const lazyModules = findLazyModules(path.resolve(projectRoot, sourceDir));
14-
const entries = Object.assign({
15-
main: [path.join(sourceRoot, 'main.ts')],
16-
polyfills: path.join(sourceRoot, 'polyfills.ts')
17-
}, lazyModules);
18-
1913

2014
return {
2115
devtool: 'source-map',
@@ -24,31 +18,15 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
2418
root: path.resolve(projectRoot, `./${sourceDir}`)
2519
},
2620
context: path.resolve(__dirname, './'),
27-
entry: entries,
21+
entry: {
22+
main: [path.join(sourceRoot, 'main.ts')],
23+
polyfills: path.join(sourceRoot, 'polyfills.ts')
24+
},
2825
output: {
2926
path: path.resolve(projectRoot, './dist'),
3027
filename: '[name].bundle.js'
3128
},
3229
module: {
33-
preLoaders: [
34-
{
35-
test: /\.js$/,
36-
loader: 'source-map-loader',
37-
exclude: [
38-
path.resolve(projectRoot, 'node_modules/rxjs'),
39-
path.resolve(projectRoot, 'node_modules/@angular'),
40-
]
41-
},
42-
{
43-
test: /(systemjs_component_resolver|system_js_ng_module_factory_loader)\.js$/,
44-
loader: 'string-replace-loader',
45-
query: {
46-
search: '(lang_1(.*[\\n\\r]+\\s*\\.|\\.))?(global(.*[\\n\\r]+\\s*\\.|\\.))?(System|SystemJS)(.*[\\n\\r]+\\s*\\.|\\.)import\\(',
47-
replace: 'System.import("" + ',
48-
flags: 'g'
49-
}
50-
},
51-
],
5230
loaders: [
5331
{
5432
test: /\.ts$/,
@@ -75,13 +53,14 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
7553
]
7654
},
7755
plugins: [
56+
new webpack.ContextReplacementPlugin(/.*/, sourceRoot, lazyModules),
7857
new atl.ForkCheckerPlugin(),
7958
new HtmlWebpackPlugin({
8059
template: path.resolve(projectRoot, `./${sourceDir}/index.html`),
8160
chunksSortMode: 'dependency'
8261
}),
8362
new webpack.optimize.CommonsChunkPlugin({
84-
name: 'polyfills'
63+
name: ['polyfills']
8564
}),
8665
new webpack.optimize.CommonsChunkPlugin({
8766
minChunks: Infinity,
@@ -93,7 +72,7 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
9372
context: path.resolve(projectRoot, './public'),
9473
from: '**/*',
9574
to: path.resolve(projectRoot, './dist')
96-
}]),
75+
}])
9776
],
9877
node: {
9978
fs: 'empty',

0 commit comments

Comments
 (0)