-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
107 lines (105 loc) · 2.92 KB
/
webpack.config.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
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
var ROOT_PATH = path.resolve(__dirname);
var SRC_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'dist');
module.exports = {
entry: {
index: path.resolve(SRC_PATH, 'index.jsx')
},
output: {
path: BUILD_PATH,
filename: 'js/[name].[hash:5].js'
},
//开启dev source map
devtool: 'eval-source-map',
//开启 webpack dev server
devServer: {
historyApiFallback: true,
hot: true,
inline: true, //实时刷新
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
rules: [
// {
// test: /\.jsx?$/,
// loaders: ['eslint-loader'],
// include: SRC_PATH,
// }, {
{
test: /\.(html)$/,
use: {
loader: 'html-loader',
options: {
attrs: [':data-src']
}
}
},
{
test: /\.jsx?$/,
loaders: ['babel-loader'],
include: SRC_PATH,
exclude: path.resolve(ROOT_PATH, 'node_modules')
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192'
},
{
test: /\.md$/,
use: [
{
loader: "html-loader"
},
{
loader: "markdown-loader",
options: {
/* your options here */
}
}
]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
]
},
// 配置plugin
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"development"'
}),
// new webpack.optimize.UglifyJsPlugin({
// sourceMap: true,
// }),
new HtmlWebpackPlugin({
title: 'cbreno',
filename: 'index.html',
template: path.resolve(ROOT_PATH, 'templates', 'index.html'),
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
removeAttributeQuotes: true
}
})
],
optimization: {
minimize: false,
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
compress: false
}
})
]
}
};