-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.babel.js
81 lines (78 loc) · 1.98 KB
/
webpack.config.dev.babel.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
import webpack from 'webpack';
import StyleLintPlugin from 'stylelint-webpack-plugin';
import base from './webpack.config.babel';
import BrowserSyncPlugin from 'browser-sync-webpack-plugin';
import websiteJson from './config/website.json';
import pugLintConfig from './.pug-lintrc.json';
const webpackDevConfig = {
entry: (() => {
const entryObj = {};
for (const key in base.entry) {
if ({}.hasOwnProperty.call(base.entry, key)) {
entryObj[key] = [
`webpack-dev-server/client?http://localhost:${websiteJson.port.webpackServer}`,
'webpack/hot/dev-server',
base.entry[key],
];
}
}
return entryObj;
})(),
output: base.output,
module: {
rules: base.module.rules.concat([
Object.assign(base.module.cssRule, {
use: [
'style-loader',
base.module.cssRule.use.css,
base.module.cssRule.use.postcss,
],
}),
{
enforce: 'pre',
test: /\.js$/,
include: /src\/js/,
loader: 'eslint-loader',
options: {
configFile: '.eslintrc.json',
},
},
{
enforce: 'pre',
test: /\.pug$/,
include: /src\/view/,
loader: 'pug-lint-loader',
options: Object.assign({
emitError: true,
}, pugLintConfig),
},
]),
},
plugins: [
base.plugins.webpackEnvironment,
base.plugins.loaderOptionsPlugin,
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new StyleLintPlugin({
configFile: '.stylelintrc.json',
files: ['src/css/*.css', 'src/css/**/*.css'],
}),
new BrowserSyncPlugin(
// BrowserSync options
{
// browse to http://localhost:3000/ during development
host: 'localhost',
port: websiteJson.port.browserSyncServer,
// proxy the Webpack Dev Server endpoint
// (which should be serving on http://localhost:8080/)
// through BrowserSync
proxy: `http://localhost:${
websiteJson.port.webpackServer
}/`,
files: 'src/view/*.pug',
}
),
].concat(base.plugins.htmlWebpackPlugin),
devtool: 'eval',
};
export default webpackDevConfig;