-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.dev.js
47 lines (40 loc) · 1.28 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
/**
* 开发模式对应的 webpack 配置。
* 使用 node server.js 命令启用开发模式。
*/
var path = require("path");
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var ip = 'localhost';
//引入基础配置
var config = require('./webpack.config.base');
//每个module会通过eval()来执行,并且生成一个DataUrl形式的SourceMap.
config.devtool = "#eval-source-map";
//修改入口
config.entry.app = [
'webpack-dev-server/client?http://' + ip + ':3000',
'webpack/hot/only-dev-server',
'./html/main',
];
// Tell django to use this URL to load packages and not use STATIC_URL + bundle_name
config.output.publicPath = 'http://' + ip + ':3000' + '/html/static/bundles/';
//添加插件
config.plugins = config.plugins.concat([
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new BundleTracker({filename: './webpack-stats-dev.json'}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('development'),
'BASE_API_URL': JSON.stringify('https://'+ ip +':8000/api/v1/'),
}}),
]);
//添加rule
config.module.rules.push(
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ['react-hot-loader', 'babel-loader']
}
);
module.exports = config;