forked from mandolin/hia-multilingual-vue-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
91 lines (83 loc) · 3.19 KB
/
vue.config.js
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
const PATH = require('path');
const PATHS = {
Prj : PATH.join(__dirname, './' ), //项目目录
Dist: PATH.join(__dirname, 'dist'), //输出目录
Src : PATH.join(__dirname, 'src' ), //源目录
};
const UGLIFYJS_PLUGIN = require('uglifyjs-webpack-plugin');
const NODE_ENV = process.env.NODE_ENV;
const WEBPACK = require('webpack' ) ;
const MULTILINGUAL_CUSTOM = require('./tool/multilingual/multilingual-custom') ;
const MULTILINGUAL = require('./tool/multilingual/multilingual') ;
//note 编译阶段嵌入全局中文标识符常量
var DefineObj= Object.assign({
//PRODUCTION: JSON.stringify(true),
//VERSION: JSON.stringify('1.0.0'),
//BROWSER_SUPPORTS_HTML5: true,
//'typeof window': JSON.stringify('object'),
//'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},MULTILINGUAL,MULTILINGUAL_CUSTOM);
module.exports = {
//公共地址根路径(亦即生产环境下或网站运行目录)
publicPath: '',
//静态文件目录
assetsDir: 'static',
//是否包含运行时编译机制
runtimeCompiler: true,
lintOnSave: true,
productionSourceMap: false,
css: {
requireModuleExtension: false,
loaderOptions: {
css: {},
postcss: {
// 这里的选项会传递给 postcss-loader
//exec: true,
//parser: 'sugarss',
plugins:[
require('postcss-import')(),
require('postcss-preset-env')(),
require('cssnano')()
]
}
}
},
chainWebpack: config => {
config.module.rule('images').use('url-loader').loader('url-loader')
.tap(options => Object.assign(options, { esModule: false }));
config.module.rule('media').use('url-loader').loader('url-loader')
.tap(options => Object.assign(options, { esModule: false }));
config.module.rule('fonts').use('url-loader').loader('url-loader')
.tap(options => Object.assign(options, { esModule: false }));
},
configureWebpack: (config) => {
config.plugins.push(
new WEBPACK.DefinePlugin(DefineObj)
);
if (NODE_ENV === 'production') {
config.plugins.push(
new UGLIFYJS_PLUGIN({
uglifyOptions: {
compress: {
//warnings: false,
drop_debugger: true, // 注释console
drop_console: true,
pure_funcs: ['console.log'] // 移除console
},
},
sourceMap: false,
parallel: true,
})
);
}
},
pluginOptions: {
'style-resources-loader': {
'preProcessor': 'sass',
'patterns': [
PATH.resolve(__dirname, './tool/multilingual/multilingual-custom.sass'),//note 将你的自定义配置文件置于你需要的地方。Put your custom configuration files in where it is needed.
PATH.resolve(__dirname, './tool/multilingual/multilingual.sass'),
]
}
}
};