-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·80 lines (73 loc) · 2.6 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
"use strict";
var path = require('path'), join = path.join.bind(path, __dirname);
var cssStr = 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss';
var autoprefixer = require('autoprefixer');
var lifecycle = process.env['npm_lifecycle_event'];
var isPrepublish = lifecycle === 'prepublish';
var isKarma = process.env['NODE_ENV'] === 'test';
var isTestDist = lifecycle === 'test-dist';
var config = {
devtool: (isPrepublish ? '#source-map' : "#inline-source-map"),
devServer: {
noInfo: true,
hot: true,
inline: true,
contentBase: join('public'),
publicPath: '/',
port: 8083
},
resolve: {
extensions: ['', '.jsx', '.js'],
alias: {
'fbjs': join('node_modules/fbjs'),
'react': join('node_modules/react'),
'Subschema': join('node_modules/subschema/dist/subschema-noreact.js'),
'subschema-external-component-example': isTestDist ? join('dist/index.js') : join('src/index.js')
}
},
stats: {
colors: true,
reasons: true
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
//do this to prevent babel from translating everything.
loader: 'babel',
include: [
join('src'),
join('public'),
isKarma ? join('test') : join('no_such_dir')
]
},
{test: /\.(png|jpe?g|mpe?g[34]?|gif)$/, loader: 'url-loader?limit=100000'},
{test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream"},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file"},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml"},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.css$/,
loader: 'style!css!postcss'
},
{
test: /\.less$/,
loader: 'style!'+cssStr+'!less'
}]
},
postcss: [autoprefixer({
browsers: ["Android 2.3", "Android >= 4",
"Chrome >= 20", "Firefox >= 24",
"Explorer >= 8", "iOS >= 6", "Opera >= 12", "Safari >= 6"]
})],
externals: (isPrepublish ? [{
'react': true,
'Subschema': true
}] : null)
};
module.exports = config;