forked from reactjs/react-magic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.development.js
77 lines (73 loc) · 2.54 KB
/
webpack.config.development.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
/**
* Created by RequireSun on 2016/12/7.
*/
'use strict';
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const cssExtractor = new ExtractTextPlugin('styleBundle.css');
// config.devServer = { hot: true, line: true, inline: true, progress: true, };
module.exports = {
entry: {
HTMLtoJSX: './src/index.js',
pageBundle: './site/htmltojsx-component.jsx',
},
output: {
path : path.resolve(__dirname, 'dist'),
filename: '[name].js',
library : '[name]',
libraryTarget: 'umd',
},
devtool: '#cheap-module-source-map',
module: {
loaders: [{
test : /\.js$/i,
loader : 'babel-loader',
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'site'),
],
query : { presets: [ 'es2015', ], },
}, {
test : /\.jsx$/i,
loader : 'babel-loader',
include: [ path.resolve(__dirname, 'site'), ],
query : { presets: [ 'react', 'es2015', ], },
}, {
test : /\.css$/i,
loader: cssExtractor.extract(['css-loader']),
}, {
test: /\.((woff2?|svg)(\?v=[0-9]\.[0-9]\.[0-9]))|(woff2?|svg|jpe?g|png|gif|ico)$/,
loaders: [
// 小于10KB的图片会自动转成dataUrl
'url-loader?limit=10240&name=img/[hash:8].[name].[ext]',
'image-webpack-loader?{bypassOnDebug:true,progressive:true,pngquant:{quality:"65-80",speed:4}}'
]
}],
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(true), // 根据调用次数分配 id
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(), // 干掉所有错误输出
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
},
}),
new HtmlWebpackPlugin({
filename: 'htmltojsx.html',
template: path.resolve(__dirname, 'site/htmltojsx.html'),
chunksSortMode: function (a, b) { //alphabetical order
if (a.names[0] > b.names[0]) {
return 1;
}
if (a.names[0] < b.names[0]) {
return -1;
}
return 0;
}
}),
cssExtractor,
],
};