forked from WANZARGEN/spaceone-design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
executable file
·113 lines (102 loc) · 3.54 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// eslint-disable-next-line @typescript-eslint/no-var-requires
const webpackBundleAnalyzer = require('webpack-bundle-analyzer');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const postcssConfig = require('./postcss.config');
/** ********************************************
* Set additional environment variables *
* ******************************************* */
process.env.VUE_APP_VERSION = require('./package.json').version;
/** ********************************************
* Set additional webpack plugins *
* ******************************************* */
const extraPlugins = [];
if (process.env.NODE_ENV === 'development') {
// const StylelintPlugin = require('stylelint-webpack-plugin');
// extraPlugins.push(
// new StylelintPlugin({
// files: ['src/**/*.{vue,scss,pcss}'],
// }),
// );
}
if (process.env.VUE_APP_ANALYZE_MOD) {
const BundleAnalyzerPlugin = webpackBundleAnalyzer.BundleAnalyzerPlugin;
extraPlugins.push(
new BundleAnalyzerPlugin(),
);
}
/** ********************************************
* Set Vue CLI config *
* ******************************************* */
module.exports = {
lintOnSave: false,
runtimeCompiler: true,
devServer: {
disableHostCheck: true,
port: 8080,
},
css: {
loaderOptions: {
postcss: postcssConfig,
sass: {
sassOptions: {
includePaths: ['./node_modules'],
},
},
},
extract: false,
},
configureWebpack: {
devtool: 'source-map',
plugins: [
...extraPlugins,
],
/*
Below is a code that removes unnecessary modules to bundling.
The modules that are removed are modules that are already installed in the application or too large.
Related issue: https://github.com/amcharts/amcharts4/issues/82#issuecomment-607546562
*/
// eslint-disable-next-line consistent-return
externals(context, request, callback) {
if (/^vue$|@vue\/composition-api|vue-router|vue-i18n|vue-fragment|@amcharts/.test(request)) {
return callback(null, `commonjs ${request}`);
}
callback();
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
loader: 'vue-loader',
options: {
esModule: false,
},
},
],
},
},
chainWebpack: (config) => {
config.module
.rule('images')
.test(/\.(png|jpe?g|gif)$/i)
.use('url-loader')
.loader('url-loader')
.tap(options => Object.assign(options, { limit: false }));
/* These are some necessary steps changing the default webpack config of the Vue CLI
that need to be changed in order for Typescript based components to generate their
declaration (.d.ts) files.
Discussed here https://github.com/vuejs/vue-cli/issues/1081
*/
config.module.rule('ts').uses.delete('cache-loader');
config.module
.rule('ts')
.use('ts-loader')
.loader('ts-loader')
.tap((opts) => {
opts.transpileOnly = false;
opts.happyPackMode = false;
opts.configFile = 'tsconfig.build.json';
return opts;
});
},
parallel: false,
};