1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-18 15:47:57 +01:00

vendor js chunk

This commit is contained in:
Kyle Spearrin 2018-07-20 22:46:03 -04:00
parent 24ee5c2d5d
commit 58818dabc5

View File

@ -17,13 +17,6 @@ if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'development'; process.env.NODE_ENV = 'development';
} }
const isVendorModule = (module) => {
if (!module.context) {
return false;
}
return module.context.indexOf('node_modules') !== -1;
};
const extractCss = new ExtractTextPlugin({ const extractCss = new ExtractTextPlugin({
filename: '[name].[chunkhash].css', filename: '[name].[chunkhash].css',
disable: false, disable: false,
@ -66,12 +59,8 @@ const moduleRules = [
test: /\.scss$/, test: /\.scss$/,
use: extractCss.extract({ use: extractCss.extract({
use: [ use: [
{ { loader: 'css-loader' },
loader: 'css-loader', { loader: 'sass-loader' },
},
{
loader: 'sass-loader',
},
], ],
publicPath: '../', publicPath: '../',
}), }),
@ -79,7 +68,7 @@ const moduleRules = [
// Hide System.import warnings. ref: https://github.com/angular/angular/issues/21560 // Hide System.import warnings. ref: https://github.com/angular/angular/issues/21560
{ {
test: /[\/\\]@angular[\/\\].+\.js$/, test: /[\/\\]@angular[\/\\].+\.js$/,
parser: { system: true } parser: { system: true },
}, },
]; ];
@ -93,7 +82,7 @@ const plugins = [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: './src/index.html', template: './src/index.html',
filename: 'index.html', filename: 'index.html',
chunks: ['app/polyfills', 'app/main'], chunks: ['app/polyfills', 'app/vendor', 'app/main'],
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: './src/connectors/duo.html', template: './src/connectors/duo.html',
@ -168,6 +157,19 @@ const config = {
externals: { externals: {
'u2f': 'u2f', 'u2f': 'u2f',
}, },
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'app/vendor',
chunks: (chunk) => {
return chunk.name === 'app/main';
},
},
},
},
},
resolve: { resolve: {
extensions: ['.ts', '.js'], extensions: ['.ts', '.js'],
alias: { alias: {