This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.dev.config.js
104 lines (102 loc) · 3.15 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
100
101
102
103
104
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
var autoprefixer = require('autoprefixer');
var devConfig = {
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
entry: [
'./app/app.jsx',
'webpack/hot/dev-server',
'webpack-hot-middleware/client'
],
output: {
publicPath: (process.env.HOST || 'http://localhost:3000') + '/',
path: '/',
filename: 'js/app.js'
},
mode: 'development',
devtool: 'source-map',
resolve: {
extensions: ['.js', '.jsx']
},
module: {
rules: [
{
test: /\.jsx?$/,
enforce: 'pre',
use: ['eslint-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
'postcss-loader?' + JSON.stringify([autoprefixer()])
]
},
{
test: /\.m?jsx?$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: 3
}
],
'@babel/preset-react'
]
}
}
},
{
test: /\.(eot|ttf|woff|woff2|otf)$/,
use: 'url-loader'
},
{
test: /\.(png|jpg|jpeg|gif|woff|svg|mp4)$/,
use: 'file-loader'
}
]
},
plugins: [
// inject styles and javascript into index.html
new HtmlWebpackPlugin({
title: 'Webpack Build',
template: './app/index-dev.html'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"development"'
}),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
'build/logo-title.png',
'build/logo.png',
'build/logo-media.png',
'build/fonts',
'build/js',
'build/styles',
'build/index.html'
]
}),
new CopyWebpackPlugin([
{ from: './static/m13/favicon.png', to: './logo.png' },
{ from: './static/m13/logo.png', to: './logo-title.png' },
{ from: './static/m13/media.png', to: './logo-media.png' },
{ from: './app/favicon/', to: './favicon/' },
{ from: './app/fonts/', to: './fonts/' }
]),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
]
};
module.exports = devConfig;