-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathwebpack.config.js
85 lines (83 loc) · 2.18 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
const path = require('path');
const WebpackAssetsManifest = require('webpack-assets-manifest');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { NODE_ENV } = process.env;
const isProd = NODE_ENV === 'production';
module.exports = {
mode: isProd ? 'production' : 'development',
devtool: isProd ? false : 'source-map',
entry: {
application: [
'@fortawesome/fontawesome-free/js/all.js',
path.resolve(__dirname, 'front', 'index.scss'),
path.resolve(__dirname, 'front', 'index.ts')
]
},
output: {
path: path.resolve(__dirname, 'public', 'packs'),
publicPath: isProd ? '/packs/' : '//localhost:8080/packs/',
filename: isProd ? '[name]-[contenthash].js' : '[name].js'
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js']
},
module: {
rules: [
{
test: /\.(tsx?|js)$/,
use: 'babel-loader',
include: path.resolve(__dirname, 'front')
},
{
test: /\.(s?css)$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{
test: /\.(svg|png|gif|eot|ttf|woff2?)$/,
use: [
{
loader: 'file-loader',
options: {
name: isProd ? '[name]-[contenthash].[ext]' : '[name].[ext]',
}
}
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: isProd ? '[name]-[contenthash].css' : '[name].css',
}),
new WebpackAssetsManifest({
publicPath: true,
output: 'manifest.json',
writeToDisk: true
}),
new CaseSensitivePathsPlugin()
],
devServer: {
server: 'https',
port: 8080,
allowedHosts: 'all',
headers: {
'Access-Control-Allow-Origin': '*'
},
proxy: {
context: (pathname) => {
return !pathname.startsWith('/asset_pack/');
},
target: 'http://localhost:3000',
changeOrigin: true,
onProxyReq: (proxyReq, req) => {
proxyReq.setHeader('X-Forwarded-Proto', 'https');
proxyReq.setHeader('Host', req.headers.host);
}
}
}
};