| | |
| | | const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') |
| | | const UglifyJsPlugin = require('uglifyjs-webpack-plugin') |
| | | |
| | | const env = require('../config/prod.env') |
| | | // const env = require('../config/prod.env') |
| | | const env = |
| | | process.env.NODE_ENV_SELF === "production" ? |
| | | require("../config/prod.env") : process.env.NODE_ENV_SELF === 'test' ? |
| | | require("../config/test.env") : require("../config/dev.env"); |
| | | |
| | | const webpackConfig = merge(baseWebpackConfig, { |
| | | module: { |
| | |
| | | }, |
| | | devtool: config.build.productionSourceMap ? config.build.devtool : false, |
| | | output: { |
| | | path: config.build.assetsRoot, |
| | | // path: config.build.assetsRoot, |
| | | //区分开发环境与生产环境或测试环境 |
| | | path: process.env.NODE_ENV_SELF === "production" ? |
| | | config.build.assetsRoot : process.env.NODE_ENV_SELF === 'test' ? |
| | | config.build_test.assetsRoot : config.build_dev.assetsRoot, |
| | | |
| | | filename: utils.assetsPath('js/[name].[chunkhash].js'), |
| | | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') |
| | | }, |
| | |
| | | // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. |
| | | // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, |
| | | // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 |
| | | allChunks: true, |
| | | allChunks: false, |
| | | }), |
| | | // Compress extracted CSS. We are using this plugin so that possible |
| | | // duplicated CSS from different components can be deduped. |
| | | new OptimizeCSSPlugin({ |
| | | cssProcessorOptions: config.build.productionSourceMap |
| | | ? { safe: true, map: { inline: false } } |
| | | : { safe: true } |
| | | cssProcessorOptions: config.build.productionSourceMap ? |
| | | { safe: true, map: { inline: false } } : |
| | | { safe: true } |
| | | }), |
| | | // generate dist index.html with correct asset hash for caching. |
| | | // you can customize output by editing /index.html |
| | | // see https://github.com/ampedandwired/html-webpack-plugin |
| | | new HtmlWebpackPlugin({ |
| | | filename: config.build.index, |
| | | // filename: config.build.index, |
| | | filename: process.env.NODE_ENV_SELF === "production" ? |
| | | config.build.index : process.env.NODE_ENV_SELF === "test" ? |
| | | config.build_test.index : config.build_dev.index, |
| | | |
| | | template: 'index.html', |
| | | inject: true, |
| | | favicon: './favicon.ico', |
| | | minify: { |
| | | removeComments: true, |
| | | collapseWhitespace: true, |
| | |
| | | }), |
| | | |
| | | // copy custom static assets |
| | | new CopyWebpackPlugin([ |
| | | { |
| | | new CopyWebpackPlugin([{ |
| | | from: path.resolve(__dirname, '../static'), |
| | | to: config.build.assetsSubDirectory, |
| | | // to: config.build.assetsStaticPath, |
| | | to: process.env.NODE_ENV_SELF === "production" ? |
| | | config.build.assetsStaticPath : process.env.NODE_ENV_SELF === "test" ? |
| | | config.build_test.assetsStaticPath : config.build_dev.assetsStaticPath, |
| | | ignore: ['.*'] |
| | | } |
| | | ]) |
| | | }]) |
| | | ] |
| | | }) |
| | | |