/
webpack.config.babel.js
87 lines (84 loc) 路 1.9 KB
/
webpack.config.babel.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
/**
* @author Gustavo Garc铆a
*
*/
import path from 'path';
import webpack from 'webpack';
import autoprefixer from 'autoprefixer';
import postcssNesting from 'postcss-nesting';
import postcssImport from 'postcss-import';
import cssnano from 'cssnano';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
export default {
entry: {
index: './src/main'
},
output: {
path: './dist',
filename: '[name].js',
libraryTarget: 'umd'
},
externals: {
'react': {
'commonjs': 'react',
'commonjs2': 'react',
'amd': 'react',
'root': 'React'
},
'react-dom': {
'commonjs': 'react-dom',
'commonjs2': 'react-dom',
'amd': 'react-dom',
'root': 'ReactDOM'
}
},
module: {
loaders: [
{
test: /\.js[x]?$/,
loader: 'babel',
exclude: /node_modules/
},
/*{
test: /\.css?$/,
loader: 'style!css?modules&importLoaders=1&localIdentName=[local]_[hash:base64:5]!postcss'
},*/
{
test: /\.css?$/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[local]_[hash:base64:5]!postcss')
},
{
test: /\.gif?$/,
loader: "url-loader?mimetype=image/gif"
},
{
test: /\.png?$/,
loader: "url-loader?mimetype=image/png"
}
]
},
resolve: {
root: [path.resolve('./src')],
extensions: ['', '.js', '.jsx']
},
postcss: (webpack) => {
return [
autoprefixer,
postcssImport({
addDependencyTo: webpack
}),
postcssNesting,
cssnano({ zindex: false })
]
},
plugins: [
new webpack.ProvidePlugin({
'Promise': 'exports?global.Promise!es6-promise',
'fetch': 'exports?self.fetch!whatwg-fetch'
}),
new ExtractTextPlugin('./react-artwork.min.css')
],
devtool: 'source-map',
stats: { colors: true },
watch: true
}