-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.dev.js
More file actions
73 lines (71 loc) · 1.98 KB
/
Copy pathwebpack.config.dev.js
File metadata and controls
73 lines (71 loc) · 1.98 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
const ReactHotLoader = require('react-hot-loader/patch');
const path = require('path')
const jsPath = 'public/javascripts/'
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const webpack = require('webpack');
// the clean options to use
const cleanOptions = {
exclude: ['error.html'],
verbose: true,
dry: false
}
module.exports = {
devtool: '#cheap-module-eval-source-map',
entry: {
'main': path.join(__dirname, jsPath + 'webpack_entry/main.js')
},
output: {
path: path.join(__dirname, 'public'),
filename: '[name].bundle.js',
publicPath: '/'
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
// {
// test: /\.css$/,
// use: ExtractTextPlugin.extract({
// fallback: "style-loader",
// use: "css-loader"
// })
// },
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test:/\.scss$/,
loader: 'css-loader!sass-loader'
}
]
},
plugins: [
// new CleanWebpackPlugin([ // 看起来在watch的状态下并没有执行,必须得手动执行打包命令才生效,如何优化?
// 'main.*.bundle.js', 'main.*.css',
// 'main.*.bundle.js.gz', 'main.*.css.gz',
// ], cleanOptions),
new HtmlWebpackPlugin({
filename: 'main.html',
template: path.join(__dirname, 'views/index.html')
}),
// new ExtractTextPlugin({
// filename: "[name].[contenthash:8].css",
// }),
// new CompressionPlugin({
// asset: "[path].gz[query]",
// algorithm: "gzip",
// test: /\.js$|\.css$|\.html$/,
// threshold: 10240,
// minRatio: 0.8
// }),
// new webpack.HotModuleReplacementPlugin(),
],
// target: 'web'
};