const moment = require('moment');css
const now = moment().format("YYYYMMDDHHmm"); //生成帶日期的文件夾webpack
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); //去console插件web
module.exports = {babel
baseUrl: './', // 基本路徑
outputDir: 'dist/'+now, // 輸出文件目錄
runtimeCompiler: false,
chainWebpack: (config) => {
config.entry = ["babel-polyfill", "./src/main.js"]
},
filenameHashing:true,
configureWebpack: config => {
// 引入註銷控制檯輸出的插件
config.plugins.push(
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false,
drop_console: true,//console
drop_debugger: false,
pure_funcs: ['console.log']//移除console
},
},
sourceMap: false,
parallel: true,
}),
)
},
productionSourceMap: false, // 生產環境是否生成 sourceMap 文件
// css相關配置
css: {
extract: true,
sourceMap: false,
loaderOptions: {}, // 爲全部的 CSS 及其預處理文件開啓 CSS Modules。
modules: false
},
parallel: require('os').cpus().length > 1,
pwa: {},
// webpack-dev-server 相關配置
devServer: {
open: process.platform === 'darwin',
host: '0.0.0.0',
port: 8080,
// disableHostCheck: true,
proxy: { // 設置代理
'/v1/*': {
target:'http://www.baidu.com/',
changeOrigin: true,
secure: false
},
},
before: app => {}
}
複製代碼
}app