-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.client.config.js
83 lines (82 loc) · 1.96 KB
/
webpack.client.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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = {
entry: {
app: "./src/app/client/index.jsx"
},
output: {
path: __dirname + "/src/dist",
filename: "[name].js",
},
module: {
rules: [
{
// Before running any of our loaders, lint our code with ESLint
enforce: "pre",
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
configFile: "./.eslintrc.json"
}
},
{
// transpile our ES6 code with Babel
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
// enable source maps for our transpiled code
test: /\.jsx?$/,
loader: 'source-map-loader'
},
{
// extract the CSS we imported as modules and inject it into the transpiled JS code
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: [/\.eot$/, /\.ttf$/, /\.woff2?$/, /\.png$/, /\.svg$/],
loader: 'file-loader',
exclude: [/\.js$/, /\.html$/, /\.json$/],
options: {
name: 'static/media/[name].[ext]'
},
}
]
},
plugins: [
// injects our bundled JS code into our HTML file inside a <script> tag
new HtmlWebpackPlugin({
inject: true,
template: './src/app/client/index.html',
favicon: './src/app/client/favicon.ico'
}),
// enable hot replacement on our dev server
new webpack.HotModuleReplacementPlugin()
],
target: 'web',
stats: {
modules: true,
reasons: true
},
resolve: {
alias: {
'components': path.resolve(__dirname, './src/app/client/components'),
'frames': path.resolve(__dirname, './src/app/client/frames'),
'utils': path.resolve(__dirname, './src/app/client/utils')
},
extensions: ['.jsx', '.js']
},
devtool: 'source-map',
// configure a dev server that can watch and reload when files change
devServer: {
port: 3000,
compress: true,
contentBase: __dirname + '/src/dist',
watchContentBase: true,
hot: true
}
};