var projectname = process.argv[3]; var glob = require("glob"); var publicPath = '' function getEntry() { var entries = {}; if (process.env.NODE_ENV == "production") { entries = { index: { // page的入口 entry: "src/views/" + projectname + "/main.js", // 模板来源 template: "public/index.html", // 在 dist/index.html 的输出 filename: "index.html", title: projectname, chunks: ["chunk-vendors", "chunk-common", "index"] } }; publicPath = '/' + projectname + '/' } else { var items = glob.sync("./src/views/*/*.js"); for (var i in items) { var filepath = items[i]; var fileList = filepath.split("/"); var fileName = fileList[fileList.length - 2]; publicPath = '/' + fileName + '/' entries[fileName] = { entry: `src/views/${fileName}/main.js`, // 模板来源 template: `public/index.html`, // 在 dist/index.html 的输出 filename: `${fileName}.html`, }; } } return entries; } const path = require('path') function resolve(dir) { return path.join(__dirname, dir) } const port = process.env.port || process.env.npm_config_port || 12004 // dev port const name = 'vue Admin Template' // page title console.log('projectname===') // console.log(process.argv) // console.log(projectname) console.log(publicPath) var pages = getEntry(); module.exports = { // publicPath:'/weibao/', publicPath: publicPath, productionSourceMap: false, // 生产禁止显示源代码 outputDir: "dist/" + projectname, pages: pages, lintOnSave: process.env.NODE_ENV === 'development', productionSourceMap: false, devServer: { port: port, open: true, overlay: { warnings: false, errors: true }, proxy: { [process.env.VUE_APP_BASE_API]: { target: 'https://test.poteviohealth.com/pmgw/', // target: 'http://localhost:12017/', changeOrigin: true, secure: false, pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: '' } } } // after: require('./mock/mock-server.js') }, configureWebpack: { // provide the app's title in webpack's name field, so that // it can be accessed in index.html to inject the correct title. name: name, resolve: { alias: { '@': resolve('src') } } }, };