-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.dev.config.js
99 lines (95 loc) · 2.22 KB
/
webpack.dev.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
88
89
90
91
92
93
94
95
96
97
98
99
const path = require('path');
const { optimize, HotModuleReplacementPlugin } = require('webpack');
const {
CommonsChunkPlugin,
} = optimize;
const webpackMerge = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const paths = require('./paths');
const webpackBaseConfig = require('./webpack.base.config');
module.exports = () => {
return webpackMerge(webpackBaseConfig, {
cache: true,
entry: {
app: [
'webpack-hot-middleware/client',
'react-hot-loader/patch',
path.resolve(paths.app, 'client.jsx'),
],
},
output: {
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
path: paths.build,
pathinfo: true,
publicPath: '/',
},
devServer: {
contentBase: paths.public,
historyApiFallback: true,
hot: true,
port: 8080,
},
devtool: 'eval-source-map',
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|cur)$/,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
{
test: /\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
},
},
'resolve-url-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-resources-loader',
options: {
resources: [
'./app/scss/base/**/_*.scss',
],
},
}
],
},
],
},
plugins: [
new HotModuleReplacementPlugin(),
new CopyWebpackPlugin([
{
context: paths.public,
from: '*.*',
},
]),
],
});
};