-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.dev.js
More file actions
81 lines (75 loc) · 2.06 KB
/
webpack.config.dev.js
File metadata and controls
81 lines (75 loc) · 2.06 KB
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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractLESS = new ExtractTextPlugin('[name].css');
const config = {
entry: [
'webpack-hot-middleware/client?reload=true',
'react-hot-loader/patch',
'webpack/hot/only-dev-server',
'./src/index.jsx',
],
devtool: 'eval-source-map',
devServer: {
contentBase: './dist',
hot: true,
port: 3000,
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
chunkFilename: '[name].bundle.js',
// sourceMapFilename: '[name].js.map',
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{ test: /\.(js|jsx)$/, use: 'babel-loader', exclude: /node_modules/ },
{
test: /\.css$/i,
use: extractLESS.extract({
use: [{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[name]__[local]--[hash:base64:5]',
},
}],
}),
},
{ test: /\.(eot|woff|woff2|svg|ttf|png|jpg|jpeg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 20, // 20K
fallback: 'file-loader', // default
name: '[path][name]-[hash:8].[ext]',
// publicPath: 'assets/',
outputPath: './imgs/',
useRelativePath: false, // true : outputPath 失效
},
}],
},
],
},
plugins: [
// new webpack.DefinePlugin({
// 'process.env.NODE_ENV': JSON.stringify('development'),
// }),
// new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './template/index_dev.html',
title: 'react-boilerplate-dev',
// chunks: ['app'], //指定要加入的entry实例,
inject: 'body',
}),
extractLESS,
],
};
module.exports = config;