-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/cli): use same webpack config for karma
- Loading branch information
1 parent
6dff3b7
commit 3bba4cb
Showing
18 changed files
with
237 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as webpack from 'webpack'; | ||
import * as path from 'path'; | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
|
||
import { packageChunkSort } from '../../utilities/package-chunk-sort'; | ||
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack'; | ||
import { extraEntryParser, lazyChunksFilter } from './utils'; | ||
import { WebpackConfigOptions } from '../webpack-config'; | ||
|
||
|
||
export function getBrowserConfig(wco: WebpackConfigOptions) { | ||
const { projectRoot, buildOptions, appConfig } = wco; | ||
|
||
const appRoot = path.resolve(projectRoot, appConfig.root); | ||
const nodeModules = path.resolve(projectRoot, 'node_modules'); | ||
|
||
let extraPlugins: any[] = []; | ||
|
||
// figure out which are the lazy loaded entry points | ||
const lazyChunks = lazyChunksFilter([ | ||
...extraEntryParser(appConfig.scripts, appRoot, 'scripts'), | ||
...extraEntryParser(appConfig.styles, appRoot, 'styles') | ||
]); | ||
|
||
if (buildOptions.vendorChunk) { | ||
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'vendor', | ||
chunks: ['main'], | ||
minChunks: (module: any) => module.resource && module.resource.startsWith(nodeModules) | ||
})); | ||
} | ||
|
||
return { | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
template: path.resolve(appRoot, appConfig.index), | ||
filename: path.resolve(buildOptions.outputPath, appConfig.index), | ||
chunksSortMode: packageChunkSort(appConfig), | ||
excludeChunks: lazyChunks, | ||
xhtml: true | ||
}), | ||
new BaseHrefWebpackPlugin({ | ||
baseHref: buildOptions.baseHref | ||
}), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
minChunks: Infinity, | ||
name: 'inline' | ||
}) | ||
].concat(extraPlugins) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
export * from './browser'; | ||
export * from './common'; | ||
export * from './development'; | ||
export * from './production'; | ||
export * from './styles'; | ||
export * from './test'; | ||
export * from './typescript'; | ||
export * from './utils'; | ||
export * from './xi18n'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.