-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
87 lines (80 loc) · 2.27 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
83
84
85
86
87
'use strict'
var path = require('path')
var fs = require('fs');
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin');
var VueLoaderPlugin = require('vue-loader/lib/plugin')
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
var OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
var isDev = process.env.NODE_ENV === 'development'
var plugins = [
new CaseSensitivePathsPlugin(),
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: 'public/style2.min.css'
}),
new HtmlWebpackPlugin({
template: './src/static/index.html'
})
]
if (isDev) {
plugins.push(new webpack.HotModuleReplacementPlugin())
}
if (!isDev) {
plugins.push(new OptimizeCSSAssetsPlugin())
}
module.exports = {
mode: isDev ? 'development' : 'production',
devtool: isDev ? 'cheap-module-eval-source-map' : '',
entry: {
app: './src/main.js'
},
context: path.resolve(__dirname),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'public/prod.js',
publicPath: '/'
},
module: {
noParse: /^(vue|vue-router|vuex|vuex-router-sync)$/,
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.css$/,
use: [
isDev ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
resolve: {
extensions: ['.mjs', '.js', '.vue', '.json', '.wasm'],
alias: {
vue$: 'vue/dist/vue.esm.js'
}
},
plugins: plugins,
devServer: {
open: false,
hot: true,
port: 8080,
compress: true,
historyApiFallback: true,
proxy: {
"/public": {
target: "http://localhost:3001",
},
// i don't know what seems to be requesting `/fonts`,
// but it now redirects to `/public/fonts`
"/fonts": {
target: "http://localhost:3001",
pathRewrite: { '^/fonts': '/public/fonts' }
}
}
}
}