-
Notifications
You must be signed in to change notification settings - Fork 1
/
component-playground.config.js
94 lines (89 loc) · 2.06 KB
/
component-playground.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
93
94
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var merge = require('webpack-merge');
var TARGET = process.env.TARGET;
var ROOT_PATH = path.resolve(__dirname);
module.exports.webpack = function(config) {
config.module.loaders.push([
{
test: /\.cjsx$/,
loaders: ['coffee', 'cjsx'],
include: path.resolve(ROOT_PATH, 'app')}
]);
return config;
};
var common = {
entry: [path.resolve(ROOT_PATH, 'app/main')],
resolve: {
extensions: ['', '.js', '.jsx', '.cjsx', '.coffee']
},
output: {
path: path.resolve(ROOT_PATH, 'build'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.css$/,
loaders: ['style', 'css']
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'React Webpack and Mocha starter'
})
]
};
if(TARGET === 'build') {
module.exports = merge(common, {
devtool: 'source-map',
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel?stage=1',
include: path.resolve(ROOT_PATH, 'app')
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
});
}
if(TARGET === 'dev') {
module.exports = merge(common, {
devtool: 'eval-source-map',
entry: [
'webpack/hot/dev-server'
],
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel?optional[]=runtime&stage=0'],
include: path.resolve(ROOT_PATH, 'app'),
},
{
test: /\.cjsx$/,
loaders: ['react-hot', 'coffee', 'cjsx'],
include: path.resolve(ROOT_PATH, 'app')},
{ test: /\.coffee$/,
loader: 'coffee',
include: path.resolve(ROOT_PATH, 'app')}
],
},
});
}