-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvue.config.js
More file actions
182 lines (177 loc) · 5.48 KB
/
vue.config.js
File metadata and controls
182 lines (177 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
const path = require('path')
// const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const webpack = require('webpack');
const isDev = process.env.NODE_ENV === 'development'
function resolve(dir) {
return path.join(__dirname, dir)
}
let assetsDir = "./static";
let getAssetsDir = function(filename) {
return path.posix.join(assetsDir, filename);
};
let uuidCharts = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
let getGUID = function(len, radix) {
var chars = uuidCharts,
uuid = [],
i;
radix = radix || chars.length;
len = len || 16;
if (len) {
// Compact form
for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
} else {
// rfc4122, version 4 form
var r;
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = "";
uuid[14] = "4";
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | (Math.random() * 16);
uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join("");
}
const externals = {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
// axios: 'axios',
jquery: '$'
}
module.exports = {
publicPath:"./",
assetsDir:assetsDir,
productionSourceMap: false,
transpileDependencies: [
/[/\\]node_modules[/\\](.+?)?vue-color(.*)/,
/[/\\]node_modules[/\\](.+?)?vuedraggable(.*)/,
/[/\\]node_modules[/\\](.+?)?sockjs-client(.*)/,
/[/\\]node_modules[/\\](.+?)?ant-design_colors(.*)[/\\]colors/,
/[/\\]node_modules[/\\](.+?)?moment(.*)[/\\]moment/,
],
pages:{
index: {
// page 的入口
entry: 'src/main.js',
// 模板来源
template: 'public/index.html',
// 在 dist/index.html 的输出
filename: 'index.html',
// 当使用 title 选项时,
// template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: '',
includeScripts: [
"./lib/vue.min.js",
"./lib/jquery.min.js",
"./lib/axios.min.js",
"./lib/qs.js",
"./lib/lodash.min.js",
"./lib/idm.core.js",
"./lib/iconfont/iconfont.js"
],
includeCss:[
"./lib/idm.base.css"
]
},
},
chainWebpack(config) {
config.externals(externals)
config
.plugin('define')
.tap(args => {
args[0]['process.env.CodeVar'] = JSON.stringify("CodeVar_"+getGUID()+"_"+new Date().getTime());
return args
})
// 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()
/**
* 图片打包不转换base64,可自由选择启用还是不启用,如果小的图片比较多的时候建议启用这个
*/
// config.module
// .rule("images")
// .test(/\.(png|jpe?g|gif|webp)(\?.*)?$/)
// .use("url-loader")
// .loader("url-loader")
// .options({
// name: getAssetsDir(`img/[name].[hash:8].[ext]`),
// limit: 1
// })
// config
// .plugin('webpack-bundle-analyzer')
// .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
},
configureWebpack: {
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
// new MiniCssExtractPlugin({
// // 修改打包后css文件名
// filename: `${assetsDir}/css/[name].css`,
// chunkFilename: `${assetsDir}/css/[name].css`
// })
],
output: {
// 输出重构 打包编译后的 文件名称
filename: `${assetsDir}/js/[name].js`,
// chunkFilename: `${assetsDir}/js/[name].js`,
jsonpFunction:JSON.stringify("webpackJsonp_"+getGUID()+"_"+new Date().getTime())
},
resolve:{
extensions: ['.js', '.vue', '.json'],
alias: {
//按需引入ant design的图标,防止打包文件过大
'@ant-design/icons/lib/dist$': resolve('src/plugins/antdicons.js')
}
}
},
css: {
// 是否使用css分离插件 ExtractTextPlugin
extract: isDev ? false : {
filename: `${assetsDir}/css/[name].css`,
// chunkFilename: `${assetsDir}/css/[name].css`
},
// 开启 CSS source maps?
sourceMap: isDev,
// css预设器配置项
// 启用 CSS modules for all css / pre-processor files.
requireModuleExtension: true,
loaderOptions: {
// 给 sass-loader 传递选项
sass: {
// @/ 是 src/ 的别名
// 所以这里假设你有 `src/variables.sass` 这个文件
// 注意:在 sass-loader v8 中,这个选项名是 "prependData"
// prependData: `@import "@/style/common/common.scss";`
}
}
},
devServer: {
proxy: {
'^/DreamWeb/*': {
target: "http://localhost:8080",
changeOrigin: true,
secure: false
}
}
}
}