-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.js
101 lines (99 loc) · 2.46 KB
/
webpack.config.dev.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const DEV_PORT = '8090';
module.exports = () => ({
context: __dirname,
devServer: {
compress: true,
historyApiFallback: true,
hot: true,
liveReload: false,
overlay: true,
port: DEV_PORT
},
devtool: 'eval-cheap-module-source-map',
entry: [
'react-hot-loader/patch',
'webpack/hot/only-dev-server',
'@babel/polyfill',
'classlist-polyfill',
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'src', 'scss', 'main.scss')
],
mode: 'development',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [{ loader: 'babel-loader' }]
},
{
test: /\.css$/i,
exclude: /node_modules/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { url: false } }
]
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { url: false } },
{ loader: 'postcss-loader' },
{ loader: 'sass-loader' }
]
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.scss'],
modules: [
'node_modules',
path.resolve(__dirname, 'src')
],
symlinks: false,
alias: {
'react-dom': '@hot-loader/react-dom',
'Components': path.resolve(__dirname, 'src', 'components'),
'Utils': path.resolve(__dirname, 'src', 'utils')
}
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'public')
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({ DEBUG: true }),
new webpack.ProvidePlugin({
axios: 'axios',
moment: 'moment',
PropTypes: 'prop-types',
React: 'react',
ReactDOM: 'react-dom'
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src', 'template.html'),
inject: 'body'
}),
new CircularDependencyPlugin({
exclude: /node_modules/,
failOnError: true
}),
new CopyPlugin({
patterns: [
{
force: true,
from: path.resolve(__dirname, 'assets'),
to: path.resolve(__dirname, 'public', 'assets')
}
]
})
]
});