187 lines
5.3 KiB
JavaScript
187 lines
5.3 KiB
JavaScript
'use strict';
|
||
const path = require('path');
|
||
const webpack = require('webpack');
|
||
// const defaultSettings = require('./src/settings.js')
|
||
module.exports = {
|
||
lintOnSave: false,
|
||
runtimeCompiler: true
|
||
};
|
||
|
||
function resolve(dir) {
|
||
return path.join(__dirname, dir);
|
||
}
|
||
|
||
// const name = defaultSettings.title || '绿色机关服务平台' // page title
|
||
// If your port is set to 80,
|
||
// use administrator privileges to execute the command line.
|
||
// For example, Mac: sudo npm run
|
||
const port = 8080; // dev port
|
||
// const port = 9527; // dev port
|
||
|
||
// All configuration item explanations can be find in https://cli.vuejs.org/config/
|
||
module.exports = {
|
||
/**
|
||
* You will need to set publicPath if you plan to deploy your site under a sub path,
|
||
* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
|
||
* then publicPath should be set to "/bar/".
|
||
* In most cases please use '/' !!!
|
||
* Detail: https://cli.vuejs.org/config/#publicpath
|
||
*/
|
||
publicPath: './',
|
||
outputDir: 'dist',
|
||
assetsDir: 'static',
|
||
// lintOnSave: process.env.NODE_ENV === 'development',
|
||
lintOnSave: false,
|
||
productionSourceMap: false,
|
||
devServer: {
|
||
port: port,
|
||
open: false,
|
||
overlay: {
|
||
warnings: false,
|
||
errors: true
|
||
},
|
||
proxy: {
|
||
[process.env.VUE_APP_BASE_API]: {
|
||
// target:'http://127.0.0.1:8080/',
|
||
//部署打包
|
||
// target:'http://59.1.14.137:17002/',
|
||
//i国网
|
||
// target: 'http://36.33.24.132:17002/',
|
||
|
||
// target:'http://172.20.10.3:8080/',
|
||
//刘雷
|
||
// target:'http://192.168.1.61:8080/',
|
||
//正式环境153,152
|
||
// target:'http://10.4.84.152:17101',
|
||
//王柏为
|
||
// target:'http://192.168.138.66:8080',
|
||
// target:'http://10.4.84.164:17101',
|
||
// target:'http://192.168.137.42:8080',
|
||
// target:'http://192.168.138.136:8080',
|
||
// 192.168.138.139:8087
|
||
// target:'http://192.168.138.219:8080/',
|
||
// target:'http://47.111.188.136:8383/',
|
||
// target:'http://192.168.138.214:8080/',
|
||
|
||
|
||
// target: 'http://27.196.156.66:8080', // 正伟
|
||
// target: 'http://27.196.156.53:8080', // 孔铭君
|
||
// target: 'http://10.137.2.31:48080', // 张政
|
||
// target: 'http://10.137.43.97:48080', // 鹏飞
|
||
// target: 'http://27.196.156.12:18086', // 文豪
|
||
// target: 'http://10.137.22.253:48080', // 用情
|
||
// target: 'http://10.137.2.164:48080', // 正伟
|
||
|
||
// target: 'http://jysoft-gateway:48080',
|
||
|
||
// target: 'http://10.4.84.153:17101',
|
||
// target: 'http://10.4.84.152:17101',
|
||
target: 'http://192.168.0.246:48080',
|
||
|
||
|
||
changeOrigin: true,
|
||
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: '',
|
||
resolve: {
|
||
alias: {
|
||
'vue$': "vue/dist/vue.esm.js"
|
||
}
|
||
}
|
||
},
|
||
chainWebpack(config) {
|
||
config.plugins.delete('preload'); // TODO: need test
|
||
config.plugins.delete('prefetch'); // TODO: need test
|
||
//提供全局的变量,在模块中使用无需用require引入
|
||
config.plugin('jquery').use(webpack.ProvidePlugin, [{
|
||
$: 'jquery',
|
||
jQuery: 'jquery',
|
||
'window.jQuery': 'jquery',
|
||
cube: [path.resolve('src/utils/Cube.js'), 'default'],
|
||
$config: [path.resolve('src/config/index.js'), 'default'],
|
||
$messages: [path.resolve('src/locales/zh_CN/messages.js'), 'default']
|
||
}]);
|
||
|
||
// set svg-sprite-loader
|
||
config.module
|
||
.rule('svg')
|
||
.exclude.add(resolve('src/icons'))
|
||
.end();
|
||
config.module
|
||
.rule('icons')
|
||
.test(/\.svg$/)
|
||
.include.add(resolve('src/icons'))
|
||
.end()
|
||
.use('svg-sprite-loader')
|
||
.loader('svg-sprite-loader')
|
||
.options({
|
||
symbolId: 'icon-[name]'
|
||
})
|
||
.end();
|
||
|
||
// set preserveWhitespace
|
||
config.module
|
||
.rule('vue')
|
||
.use('vue-loader')
|
||
.loader('vue-loader')
|
||
.tap(options => {
|
||
options.compilerOptions.preserveWhitespace = true;
|
||
return options;
|
||
})
|
||
.end();
|
||
|
||
config
|
||
// https://webpack.js.org/configuration/devtool/#development
|
||
.when(process.env.NODE_ENV === 'development',
|
||
config => config.devtool('cheap-source-map')
|
||
);
|
||
|
||
config
|
||
.when(process.env.NODE_ENV !== 'development',
|
||
config => {
|
||
config
|
||
.plugin('ScriptExtHtmlWebpackPlugin')
|
||
.after('html')
|
||
.use('script-ext-html-webpack-plugin', [{
|
||
// `runtime` must same as runtimeChunk name. default is `runtime`
|
||
inline: /runtime\..*\.js$/
|
||
}])
|
||
.end();
|
||
config
|
||
.optimization.splitChunks({
|
||
chunks: 'all',
|
||
cacheGroups: {
|
||
libs: {
|
||
name: 'chunk-libs',
|
||
test: /[\\/]node_modules[\\/]/,
|
||
priority: 10,
|
||
chunks: 'initial' // only package third parties that are initially dependent
|
||
},
|
||
elementUI: {
|
||
name: 'chunk-elementUI', // split elementUI into a single package
|
||
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
||
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
|
||
},
|
||
commons: {
|
||
name: 'chunk-commons',
|
||
test: resolve('src/components'), // can customize your rules
|
||
minChunks: 3, // minimum common number
|
||
priority: 5,
|
||
reuseExistingChunk: true
|
||
}
|
||
}
|
||
});
|
||
config.optimization.runtimeChunk('single');
|
||
}
|
||
);
|
||
}
|
||
};
|