forked from terraforming-mars/terraforming-mars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (76 loc) · 2.15 KB
/
webpack.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
const webpack = require('webpack');
// Makes the .vue file format parseable.
const {VueLoaderPlugin} = require('vue-loader');
// Compresses resources for smaller download.
const CompressionPlugin = require('compression-webpack-plugin');
// Speeds up typescript type checking into a separate process.
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
// Enables the tsconfig-paths behavior in webpack. tsconfig-paths is responsible for the
// import mapping that often begins with @.
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const zlib = require('zlib');
const plugins = [
new ForkTsCheckerWebpackPlugin({
typescript: {
configOverwrite: {
exclude: [
'tests/**/*.ts',
],
},
extensions: {
vue: true,
},
},
}),
new VueLoaderPlugin(),
];
if (process.env.NODE_ENV === 'production') {
plugins.push(new CompressionPlugin());
plugins.push(new CompressionPlugin({
algorithm: 'brotliCompress',
filename: '[path][base].br',
compressionOptions: {params: {[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY}},
}));
}
if (process.env.NODE_ENV === 'development') {
// Reports progress on the commandline during compilation.
plugins.push(new webpack.ProgressPlugin());
}
module.exports = {
devtool: 'source-map',
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry: './src/client/main.ts',
resolve: {
plugins: [new TsconfigPathsPlugin()],
extensions: ['.ts', '.vue', '.js'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {appendTsSuffixTo: [/\.vue$/], transpileOnly: true},
},
{
test: /\.css$/,
use: ['vue-style-loader', 'css-loader?url=false'],
},
{
test: /\.less$/,
use: ['vue-style-loader', 'css-loader?url=false', 'less-loader'],
},
],
},
plugins,
output: {
path: __dirname + '/build',
hashFunction: 'xxhash64',
},
};