This repository has been archived by the owner on May 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
webpack.config.dev.js
117 lines (103 loc) · 2.85 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* eslint-disable indent */
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
const sourceDir = path.join(__dirname, './app');
const dllManifest = require('./dll/libs-manifest.json');
const entryPath = path.join(sourceDir, './index.js');
const host = process.env.HOST || 'localhost';
const port = process.env.PORT || 8000;
module.exports = require('./webpack.config.base')({
mode: 'development',
entry: {
front: [
// activate HMR for React
'react-hot-loader/patch',
// bundle the client for webpack-dev-server
// and connect to the provided endpoint
`webpack-dev-server/client?http://${host}:${port}`,
// bundle the client for hot reloading
// only- means to only hot reload for successful updates
'webpack/hot/only-dev-server',
// the entry point of our app
entryPath,
],
},
// devtool: 'source-map',
output: {
filename: '[name].js',
chunkFilename: '[name].js',
},
optimization: {
namedModules: true,
noEmitOnErrors: true,
},
plugins: [
// import dll manifest
new webpack.DllReferencePlugin({
context: path.resolve(__dirname, '.'),
manifest: dllManifest,
}),
new HtmlWebpackPlugin({
inject: true,
chunks: ['front'],
filename: 'index.html',
template: 'index.dev.ejs',
}),
// make DLL assets available for the app to download
new AddAssetHtmlPlugin([{ filepath: require.resolve('./dll/libs.dll.js'), includeSourcemap: false }]),
new webpack.HotModuleReplacementPlugin(),
],
module: {
rules: [
{
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
include: sourceDir,
use: {
loader: 'file-loader',
query: {
name: 'static/[name].[ext]',
},
},
},
{
test: /\.scss$/,
include: [sourceDir],
use: [
'cache-loader',
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[path][name]__[local]',
importLoaders: 1,
context: sourceDir,
},
},
{
loader: 'sass-loader',
options: {
outputStyle: 'expanded',
sourceMap: false,
includePaths: [sourceDir, path.resolve(sourceDir, './app')],
},
},
],
},
{
test: /\.(jsx?)$/,
include: sourceDir,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: path.join(__dirname, '.babel-cache', 'dev'),
},
},
],
},
],
},
});