-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
92 lines (88 loc) · 2.55 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
/**
* Created by Robin Hsu on 16/4/20.
*/
"use strict";
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var IconsPlugin = require('icons-loader/IconsPlugin');
const RUN_TIMESTAMP = Math.round(Date.now() / 1000);
let config = {
devtool: 'source-map',
context: __dirname,
entry: {
Alert: "./test/Alert/src/",
Card: "./test/Card/src/",
Loading: "./test/Loading/src/",
Toast: "./test/Toast/src/",
Modal: "./test/Modal/src/",
Section: "./test/Section/src/",
Tabs: "./test/Tabs/src/",
Popup: "./test/Popup/src/",
},
output: {
path: __dirname + '/test',
filename: '[name]/dist/[name].all.js'
},
externals: {
"react": "window.React",
"react-dom": "window.ReactDOM"
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react', 'stage-0'],
plugins: ['transform-decorators-legacy']
}
},
{
test: /\.handlebars$/,
loader: "handlebars-loader"
},
{
test: /\.css$/,
loader: "style!css!px2rem?remUnit=50&remPrecision=8"
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!px2rem?remUnit=100&remPrecision=8!sass?outputStyle=expanded')
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(png|jpg)$/,
loader: "url-loader?limit=1000&name=img/[name]-[hash:8].[ext]"
},
{
test: /\.svg$/,
loader: 'icons-loader',
}
]
},
plugins: [
new ExtractTextPlugin('[name]/dist/[name].css', {//抽出css
disable: false,
allChunks: true
}),
new IconsPlugin({
fontName: 'zzc-icons',
timestamp: RUN_TIMESTAMP,
filenameTemplate: {
name: './icon/[name]-[hash].[ext]'
},
normalize: true,
formats: ['ttf', 'eot', 'woff', 'svg']
}),
// new webpack.DefinePlugin({
// "process.env": {
// NODE_ENV: JSON.stringify("production")
// }
// })
]
};
module.exports = config;