Create webpack analysis files (size) (#5009)
This commit is contained in:
parent
1490ba179c
commit
df76f010da
@ -26,6 +26,10 @@
|
|||||||
"Promise"
|
"Promise"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"analize": "npm run analize:lib && npm run analize:dll && npm run analize:app",
|
||||||
|
"analize:app": "WPANALIZE=1 webpack --config webpack/app --json > .build/analize.app.json && cat .build/analize.app.json | webpack-bundle-size-analyzer",
|
||||||
|
"analize:lib": "WPANALIZE=1 webpack --config webpack/libraries --json > .build/analize.lib.json && cat .build/analize.lib.json | webpack-bundle-size-analyzer",
|
||||||
|
"analize:dll": "WPANALIZE=1 webpack --config webpack/vendor --json > .build/analize.dll.json && cat .build/analize.app.json | webpack-bundle-size-analyzer",
|
||||||
"build": "npm run build:lib && npm run build:dll && npm run build:app && npm run build:embed",
|
"build": "npm run build:lib && npm run build:dll && npm run build:app && npm run build:embed",
|
||||||
"build:app": "webpack --config webpack/app",
|
"build:app": "webpack --config webpack/app",
|
||||||
"build:lib": "webpack --config webpack/libraries",
|
"build:lib": "webpack --config webpack/libraries",
|
||||||
@ -141,6 +145,7 @@
|
|||||||
"to-source": "2.0.3",
|
"to-source": "2.0.3",
|
||||||
"url-loader": "0.5.7",
|
"url-loader": "0.5.7",
|
||||||
"webpack": "2.2.1",
|
"webpack": "2.2.1",
|
||||||
|
"webpack-bundle-size-analyzer": "2.5.0",
|
||||||
"webpack-dev-middleware": "1.10.1",
|
"webpack-dev-middleware": "1.10.1",
|
||||||
"webpack-error-notification": "0.1.6",
|
"webpack-error-notification": "0.1.6",
|
||||||
"webpack-hot-middleware": "2.17.1",
|
"webpack-hot-middleware": "2.17.1",
|
||||||
|
@ -36,6 +36,7 @@ const EMBED = process.env.EMBED;
|
|||||||
|
|
||||||
const isProd = ENV === 'production';
|
const isProd = ENV === 'production';
|
||||||
const isEmbed = EMBED === '1' || EMBED === 'true';
|
const isEmbed = EMBED === '1' || EMBED === 'true';
|
||||||
|
const isAnalize = process.env.WPANALIZE === '1';
|
||||||
|
|
||||||
const entry = isEmbed
|
const entry = isEmbed
|
||||||
? {
|
? {
|
||||||
@ -215,7 +216,7 @@ module.exports = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isProd) {
|
if (!isAnalize && !isProd) {
|
||||||
const DEST_I18N = path.join(__dirname, '..', DEST, 'i18n');
|
const DEST_I18N = path.join(__dirname, '..', DEST, 'i18n');
|
||||||
|
|
||||||
plugins.push(
|
plugins.push(
|
||||||
|
@ -29,6 +29,7 @@ const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
|||||||
const EMBED = process.env.EMBED;
|
const EMBED = process.env.EMBED;
|
||||||
const ENV = process.env.NODE_ENV || 'development';
|
const ENV = process.env.NODE_ENV || 'development';
|
||||||
const isProd = ENV === 'production';
|
const isProd = ENV === 'production';
|
||||||
|
const isAnalize = process.env.WPANALIZE === '1';
|
||||||
|
|
||||||
function getBabelrc () {
|
function getBabelrc () {
|
||||||
const babelrc = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../.babelrc')));
|
const babelrc = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../.babelrc')));
|
||||||
@ -80,11 +81,13 @@ function getPlugins (_isProd = isProd) {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
const plugins = [
|
const plugins = (isAnalize
|
||||||
|
? []
|
||||||
|
: [
|
||||||
new ProgressBarPlugin({
|
new ProgressBarPlugin({
|
||||||
format: '[:msg] [:bar] ' + ':percent' + ' (:elapsed seconds)'
|
format: '[:msg] [:bar] ' + ':percent' + ' (:elapsed seconds)'
|
||||||
}),
|
})
|
||||||
|
]).concat([
|
||||||
new HappyPack({
|
new HappyPack({
|
||||||
id: 'css',
|
id: 'css',
|
||||||
threads: 4,
|
threads: 4,
|
||||||
@ -92,13 +95,15 @@ function getPlugins (_isProd = isProd) {
|
|||||||
'style-loader',
|
'style-loader',
|
||||||
'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
|
'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
|
||||||
'postcss-loader'
|
'postcss-loader'
|
||||||
]
|
],
|
||||||
|
verbose: !isAnalize
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new HappyPack({
|
new HappyPack({
|
||||||
id: 'babel-js',
|
id: 'babel-js',
|
||||||
threads: 4,
|
threads: 4,
|
||||||
loaders: [ isProd ? 'babel-loader' : 'babel-loader?cacheDirectory=true' ]
|
loaders: [ isProd ? 'babel-loader' : 'babel-loader?cacheDirectory=true' ],
|
||||||
|
verbose: !isAnalize
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
@ -128,7 +133,7 @@ function getPlugins (_isProd = isProd) {
|
|||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
failOnError: true
|
failOnError: true
|
||||||
})
|
})
|
||||||
];
|
]);
|
||||||
|
|
||||||
if (_isProd) {
|
if (_isProd) {
|
||||||
plugins.push(new webpack.optimize.UglifyJsPlugin({
|
plugins.push(new webpack.optimize.UglifyJsPlugin({
|
||||||
|
Loading…
Reference in New Issue
Block a user