This repository has been archived by the owner on Jun 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
58 lines (51 loc) · 1.56 KB
/
webpack.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
/*
* @Author: zy9@github.com/zy410419243
* @Date: 2018-05-20 13:48:08
* @Last Modified by: zy9
* @Last Modified time: 2018-08-11 16:40:24
*/
const webpack = require('webpack');
const webpackDevServer = require('webpack-dev-server');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
// const TohoLogPlugin = require('toho-log-plugin');
const TohoLogPlugin = require('./plugins/toho-log-plugin');
const { commonModule, commonPlugin } = require('./webpack.common');
let plugins = commonPlugin;
plugins.push(new webpack.HotModuleReplacementPlugin());
plugins.push(new webpack.NamedModulesPlugin());
plugins.push(new TohoLogPlugin());
const devServerOptions = {
port: 9099,
hot: true,
host: 'localhost',
noInfo: true,
clientLogLevel: 'error',
contentBase: path.join(__dirname, 'demo')
};
const webpackConfig = {
mode: 'development',
watch: false,
devtool: 'source-map',
entry: {
demo: [
'webpack-dev-server/client?http://' + devServerOptions.host + ':' + devServerOptions.port,
'webpack/hot/only-dev-server',
__dirname + '/demo',
],
// lib: [
// 'webpack-dev-server/client?http://' + devServerOptions.host + ':' + devServerOptions.port,
// 'webpack/hot/only-dev-server',
// __dirname + '/src/lib',
// ]
},
output: {
filename: 'dist/[name].[hash].js',
chunkFilename: 'vendor/[name].[hash].js',
},
plugins,
module: commonModule
};
const compiler = webpack(webpackConfig);
const server = new webpackDevServer(compiler, devServerOptions);
server.listen(devServerOptions.port, devServerOptions.host);