如图,admin和user分别是两个多页面
vue.config.js的配置如下
const isDev = process.env.NODE_ENV !== 'production'
const path = require('path')
const resolve = dir => {
return path.join(__dirname, dir)
}
const publicPath = '/'
const PAGES = {
user: {
entry: 'src/pages/user/main.js',
template: 'src/pages/user/public/index.html',
filename: 'index.html',
title: 'IVTSP',
chunks: ['chunk-vendors', 'chunk-common', 'user']
},
admin: {
entry: 'src/pages/admin/main.js',
template: 'src/pages/admin/public/operation.html',
filename: 'operation.html',
title: 'IVTSP-OPT',
chunks: ['chunk-vendors', 'chunk-common', 'admin']
}
}
let pages = {}
let dist = 'dist'
const pageName = process.argv[3]
if (isDev || !pageName) {
pages = PAGES
} else {
pages[pageName] = PAGES[pageName]
dist = `${dist}_${pageName}`
}
module.exports = {
publicPath,
outputDir: dist,
pages,
/* webpack链式操作 */
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src'))
.set('_idx', resolve('src/pages/user'))
.set('_opt', resolve('src/pages/admin'))
},
devServer: {
historyApiFallback: {
rewrites: [{
from: new RegExp(`${publicPath}operation`),
to: `${publicPath}operation.html`
}]
},
open: true
}
}
想引入一个不参与打包的config.js,现在是放在srcpagesuserpublicconfig.js
路径,然后在srcpagesuserpublicindex.html
中直接引入,但是发现定义的全局变量没有生效,引入的config.js也是报错404,求大佬指点!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…