|
|
@@ -4,23 +4,28 @@ const utils = require('./utils')
|
|
|
const config = require('../config')
|
|
|
const vueLoaderConfig = require('./vue-loader.conf')
|
|
|
|
|
|
-function resolve (dir) {
|
|
|
+// 读取环境变量
|
|
|
+const envConfig = process.env.env_config || '' // 默认为空字符串
|
|
|
+
|
|
|
+function resolve(dir) {
|
|
|
return path.join(__dirname, '..', dir)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
module.exports = {
|
|
|
context: path.resolve(__dirname, '../'),
|
|
|
entry: {
|
|
|
app: './src/main.js'
|
|
|
},
|
|
|
- output: {
|
|
|
+ output: {
|
|
|
path: config.build.assetsRoot,
|
|
|
filename: '[name].js',
|
|
|
- publicPath: process.env.NODE_ENV === 'production'
|
|
|
- ? config.build.assetsPublicPath
|
|
|
- : config.dev.assetsPublicPath
|
|
|
+ publicPath: (() => {
|
|
|
+ if (envConfig === 'prod') {
|
|
|
+ return 'https://pre.baoxianzhanggui.com/' // 正式生产环境的 CDN 地址
|
|
|
+ } else {
|
|
|
+ return config.dev.assetsPublicPath // 开发环境
|
|
|
+ }
|
|
|
+ })()
|
|
|
},
|
|
|
resolve: {
|
|
|
extensions: ['.js', '.vue', '.json'],
|
|
|
@@ -72,11 +77,7 @@ module.exports = {
|
|
|
]
|
|
|
},
|
|
|
node: {
|
|
|
- // prevent webpack from injecting useless setImmediate polyfill because Vue
|
|
|
- // source contains it (although only uses it if it's native).
|
|
|
setImmediate: false,
|
|
|
- // prevent webpack from injecting mocks to Node native modules
|
|
|
- // that does not make sense for the client
|
|
|
dgram: 'empty',
|
|
|
fs: 'empty',
|
|
|
net: 'empty',
|