-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize production build in webpack
- Loading branch information
Showing
10 changed files
with
97 additions
and
67 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,4 +1,4 @@ | ||
#!/bin/sh | ||
|
||
NODE_ENV=production npm run build | ||
npm run prod | ||
git add lib bundledOutputs |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 +1,3 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const ShakePlugin = require('webpack-common-shake').Plugin; | ||
|
||
module.exports = { | ||
entry: [ | ||
'react-hot-loader/patch', | ||
'webpack-dev-server/client?http://localhost:8081', | ||
'webpack/hot/only-dev-server', | ||
'./lib/es6/src/main.js', | ||
], | ||
output: { | ||
path: path.join(__dirname, "bundledOutputs"), | ||
filename: '[name].js', | ||
publicPath: './' | ||
}, | ||
devtool: 'inline-source-map', | ||
devServer: { | ||
hot: true, | ||
port: 8081, | ||
contentBase: './', | ||
publicPath: '/bundledOutputs/', | ||
watchOptions: { | ||
ignored: [ | ||
/node_modules/, | ||
/bundledOutputs/ | ||
] | ||
} | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify(process.env.NODE_ENV), | ||
}, | ||
}), | ||
// new ShakePlugin(), // https://github.com/indutny/webpack-common-shake/issues/16 | ||
new webpack.HotModuleReplacementPlugin() | ||
] | ||
}; | ||
module.exports = function(env = 'dev') { | ||
return require(`./webpack/webpack.${env}.js`) | ||
}; |
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,9 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
output: { | ||
path: path.join(__dirname, '..', "bundledOutputs"), | ||
filename: '[name].js', | ||
publicPath: './' | ||
}, | ||
}; |
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,29 @@ | ||
const webpack = require('webpack'); | ||
|
||
const Merge = require('webpack-merge'); | ||
const CommonConfig = require('./webpack.common.js'); | ||
|
||
module.exports = Merge(CommonConfig, { | ||
entry: [ | ||
'react-hot-loader/patch', | ||
'webpack-dev-server/client?http://localhost:8081', | ||
'webpack/hot/only-dev-server', | ||
'./lib/es6/src/main.js', | ||
], | ||
devtool: 'inline-source-map', | ||
devServer: { | ||
hot: true, | ||
port: 8081, | ||
contentBase: './', | ||
publicPath: '/bundledOutputs/', | ||
watchOptions: { | ||
ignored: [ | ||
/node_modules/, | ||
/bundledOutputs/ | ||
] | ||
} | ||
}, | ||
plugins: [ | ||
new webpack.HotModuleReplacementPlugin() | ||
] | ||
}); |
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,37 @@ | ||
const ShakePlugin = require('webpack-common-shake').Plugin; | ||
const webpack = require('webpack'); | ||
|
||
const Merge = require('webpack-merge'); | ||
const CommonConfig = require('./webpack.common.js'); | ||
|
||
module.exports = Merge(CommonConfig, { | ||
entry: [ | ||
'./lib/es6/src/main.js', | ||
], | ||
devtool: false, | ||
plugins: [ | ||
new webpack.LoaderOptionsPlugin({ | ||
minimize: true, | ||
debug: false | ||
}), | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
'NODE_ENV': JSON.stringify('production') | ||
} | ||
}), | ||
new webpack.optimize.UglifyJsPlugin({ | ||
beautify: false, | ||
mangle: { | ||
screw_ie8: true, | ||
keep_fnames: true | ||
}, | ||
compress: { | ||
warnings: false, | ||
screw_ie8: true | ||
}, | ||
comments: false, | ||
sourceMap: false | ||
}), | ||
new ShakePlugin(), // https://github.com/indutny/webpack-common-shake/issues/16 | ||
] | ||
}) |