123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 'use strict';
- /*
- * @Description: In User Settings Edit
- * @Author: your name
- * @Date: 2019-09-15 19:43:39
- * @LastEditTime: 2019-09-15 19:43:39
- * @LastEditors: your name
- */
- /**
- * 自定义输入方式
- * @type {String}
- */
- const outputDir = 'web';
- const isProduction = process.env.NODE_ENV === 'production';
- const cdn = {
- css: [],
- js: [
- 'https://cdn.bootcdn.net/ajax/libs/vue/2.6.11/vue.js',
- 'https://cdn.bootcdn.net/ajax/libs/vue-router/3.2.0/vue-router.js',
- 'https://cdn.bootcdn.net/ajax/libs/vuex/3.5.1/vuex.min.js',
- 'https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.2/index.js',
- 'https://cdn.bootcdn.net/ajax/libs/qs/6.9.4/qs.js',
- 'https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.js',
- 'https://cdn.jsdelivr.net/npm/echarts@4.9.0/dist/echarts.min.js'
- ],
- externals:{
- vue:'Vue',
- 'vue-router':'VueRouter',
- 'element-ui':'ELEMENT',
- axios:'axios',
- vuex:'Vuex',
- echarts:'echarts',
- qs:'Qs'
- }
- }
- module.exports = {
- publicPath: isProduction ? './': '/',
- devServer: {
- port: 8080,
- proxy: {
- '/apis': {
- target: isProduction ?'http://192.168.1.222:8105':'http://192.168.1.222:8105',
- ws: true, // proxy websockets
- changeOrigin: true, // needed for virtual hosted sites
- pathRewrite: {
- '^/apis': '/' // rewrite path
- }
- }
- },
- disableHostCheck: true
- },
- //关闭语法检查
- lintOnSave:false,
- //生产环境是否生成 sourceMap 文件
- productionSourceMap:false,
- //输出文件目录
- outputDir:outputDir,
- // 指定生成的 index.html 的输出路径 (相对于 outputDir)。也可以是一个绝对路径
- configureWebpack: config => {
- if(isProduction) config.externals = cdn.externals;
- },
- chainWebpack: config => {
- // 生产环境配置
- if (isProduction) {
- // 删除预加载
- config.plugins.delete('preload');
- config.plugins.delete('prefetch');
- //压缩代码
- config.optimization.minimize(true);
- // 分割代码
- config.optimization.splitChunks({
- chunks: 'all'
- })
- //生产环境注入cdn
- config.plugin('html').tap(args => {
- args[0].cdn = cdn;
- return args;
- });
- }
- },
- };
|