|
|
|
@ -10,6 +10,8 @@ const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
|
|
|
|
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
|
|
|
|
|
const eslintFormatter = require('react-dev-utils/eslintFormatter');
|
|
|
|
|
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
|
|
|
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
|
|
|
|
|
|
|
|
|
|
const paths = require('./paths');
|
|
|
|
|
const getClientEnvironment = require('./env');
|
|
|
|
|
|
|
|
|
@ -56,8 +58,8 @@ module.exports = {
|
|
|
|
|
bail: true,
|
|
|
|
|
// We generate sourcemaps in production. This is slow but gives good results.
|
|
|
|
|
// You can exclude the *.map files from the build during deployment.
|
|
|
|
|
devtool: shouldUseSourceMap ? 'nosources-source-map' : false, //正式版
|
|
|
|
|
// devtool: shouldUseSourceMap ? 'source-map' : false,//测试版
|
|
|
|
|
// devtool: shouldUseSourceMap ? 'nosources-source-map' : false, //正式版
|
|
|
|
|
devtool: shouldUseSourceMap ? 'source-map' : false,//测试版
|
|
|
|
|
// In production, we only want to load the polyfills and the app code.
|
|
|
|
|
entry: [require.resolve('./polyfills'), paths.appIndexJs],
|
|
|
|
|
output: {
|
|
|
|
@ -270,25 +272,39 @@ module.exports = {
|
|
|
|
|
// Otherwise React will be compiled in the very slow development mode.
|
|
|
|
|
new webpack.DefinePlugin(env.stringified),
|
|
|
|
|
// Minify the code.
|
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
|
compress: {
|
|
|
|
|
warnings: false,
|
|
|
|
|
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
|
|
|
// https://github.com/facebookincubator/create-react-app/issues/2376
|
|
|
|
|
// Pending further investigation:
|
|
|
|
|
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
|
|
|
comparisons: false,
|
|
|
|
|
},
|
|
|
|
|
mangle: {
|
|
|
|
|
safari10: true,
|
|
|
|
|
},
|
|
|
|
|
// new webpack.optimize.UglifyJsPlugin({
|
|
|
|
|
// compress: {
|
|
|
|
|
// warnings: false,
|
|
|
|
|
// // Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
|
|
|
// // https://github.com/facebookincubator/create-react-app/issues/2376
|
|
|
|
|
// // Pending further investigation:
|
|
|
|
|
// // https://github.com/mishoo/UglifyJS2/issues/2011
|
|
|
|
|
// comparisons: false,
|
|
|
|
|
// },
|
|
|
|
|
// mangle: {
|
|
|
|
|
// safari10: true,
|
|
|
|
|
// },
|
|
|
|
|
// output: {
|
|
|
|
|
// comments: false,
|
|
|
|
|
// // Turned on because emoji and regex is not minified properly using default
|
|
|
|
|
// // https://github.com/facebookincubator/create-react-app/issues/2488
|
|
|
|
|
// ascii_only: true,
|
|
|
|
|
// },
|
|
|
|
|
// sourceMap: shouldUseSourceMap,
|
|
|
|
|
// }),
|
|
|
|
|
//正式版上线后打开去掉debuger和console
|
|
|
|
|
new ParallelUglifyPlugin({
|
|
|
|
|
cacheDir: '.cache/',
|
|
|
|
|
uglifyJS:{
|
|
|
|
|
output: {
|
|
|
|
|
comments: false,
|
|
|
|
|
// Turned on because emoji and regex is not minified properly using default
|
|
|
|
|
// https://github.com/facebookincubator/create-react-app/issues/2488
|
|
|
|
|
ascii_only: true,
|
|
|
|
|
comments: false
|
|
|
|
|
},
|
|
|
|
|
sourceMap: shouldUseSourceMap,
|
|
|
|
|
warnings: false,
|
|
|
|
|
compress: {
|
|
|
|
|
drop_debugger: false,
|
|
|
|
|
drop_console: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
|
|
|
|
|
new ExtractTextPlugin({
|
|
|
|
|