You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

let projectName = process.argv[3]
let glob = require('glob')
// const CopyWebpackPlugin = require('copy-webpack-plugin') // 这里引入`这个CopyWebpackPlugin`插件
// let path = require('path');
function getEntry() {
let entries = {}
if (process.env.NODE_ENV == 'production') {
entries = {
index: {
// page的入口
entry: 'src/views/' + projectName + '/main.js',
// 在 dist/index.html 的输出
filename: 'index.html',
title: projectName,
chunks: ['chunk-vendors', 'chunk-common', 'index']
}
}
} else {
let items = glob.sync('./src/views/*/main.js')
for (let i in items) {
let filepath = items[i]
let fileList = filepath.split('/');
let fileName = fileList[fileList.length - 2];
entries[fileName] = {
entry: `src/views/${fileName}/main.js`,
// 在 dist/index.html 的输出
filename: `${fileName}.html`,
title: `${fileName}`,
// 提取出来的通用 chunk 和 vendor chunk。
chunks: ['chunk-vendors', 'chunk-common', fileName]
}
}
}
return entries
}
let pages = getEntry()
module.exports = {
lintOnSave: false, //禁用eslint
outputDir: 'dist/' + projectName,
productionSourceMap: false,
pages: pages,
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
devServer: {
overlay: {
// 让浏览器 overlay 同时显示警告和错误
warnings: true,
errors: true
},
contentBase: 'dist',
compress: false, //gzip
disableHostCheck: true,
port: "80",
clientLogLevel: 'error', //浏览器控制台日志默认info
open: false,
inline: true,
hot: true, //开启HMR
publicPath: '/', //默认/,确保 publicPath 总是以斜杠(/)开头和结尾。
proxy: {
'/dsideal_yy/': {
target: 'http://10.10.14.199',
changeOrigin: true,
secure: false
},
'': {
target: 'http://10.10.14.199',
pathRewrite: { "^": "/dsideal_yy/" },
changeOrigin: true,
secure: false
}
}
},
// configureWebpack:{
// plugins: [
// new CopyWebpackPlugin([
// {
// from:path.resolve(__dirname, 'src','views',projectName,'static'),
// to: path.resolve(__dirname,'dist',projectName),
// }
// ])
// ]
// }
}