This repository has been archived by the owner on Jul 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
vue.config.js
103 lines (92 loc) · 2.86 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
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const GitRevisionWebpackPlugin = require('git-revision-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const webpack = require('webpack');
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
if (!config.plugins) {
config.plugins = [];
}
// clean out the dist/ directory for each build
config.plugins.push(new CleanWebpackPlugin(['dist']));
// remove all but english (US) and korean locales from moment.js
config.plugins.push(
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en-us|ko/)
);
// Compress all files with gzip. This allows nginx to serve compressed
// responses without dynamically compressing files, saving time and CPU
// Keeps original un-compressed files in output
config.plugins.push(new CompressionPlugin());
config.plugins.push(
new MiniCssExtractPlugin({
chunkFilename: 'css/[name]-chunk.[contenthash].js',
filename: 'css/[name].[contenthash].css',
})
);
Object.assign(config.output, {
chunkFilename: 'js/[name]-chunk.[contenthash].js',
filename: 'js/[name].[contenthash].js',
});
} else {
config.optimization = {
// use actual path names in debugging in browser
namedModules: true,
};
}
config.resolve.alias = {
'@api': path.join(__dirname, 'src/api'),
'@fixtures': path.join(__dirname, 'src/__fixtures__'),
'@src': path.join(__dirname, 'src'),
'@views': path.join(__dirname, 'src/views'),
};
const gitRevisionPlugin = new GitRevisionWebpackPlugin({
versionCommand: 'describe --tags --long',
});
config.plugins.push(gitRevisionPlugin);
config.plugins.push(
new HtmlWebpackPlugin({
template: './src/index.html',
favicon: './src/assets/favicon.ico',
})
);
config.plugins.push(
new webpack.DefinePlugin({
CONCH: {
GLOBALS: {
apiUrl: JSON.stringify('http://localhost:5001'),
conchUIVersion: JSON.stringify(gitRevisionPlugin.version()),
},
},
})
);
},
devServer: {
contentBase: './dist',
hot: true,
open: true,
overlay: {
errors: false,
warnings: false,
},
proxy: {
'/': {
target: 'http://localhost:5001',
ws: false,
},
},
},
filenameHashing: false,
pages: {
index: {
entry: 'src/main.js',
template: 'src/index.html',
filename: 'index.html',
title: 'Conch',
chunks: ['chunk-vendors', 'chunk-common', 'index'],
},
},
};