-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
77 lines (67 loc) · 1.92 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
import path from 'path'
import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin'
const config = {
entry: [
'babel-polyfill',
'./index.js',
],
output: {
filename: '[name].[hash].js',
path: path.join(__dirname, 'build'),
libraryTarget: 'umd',
},
devServer: {
historyApiFallback: true,
},
devtool: 'source-map',
module: {
preLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['eslint'],
},
{
test: /emoji.less$/,
loader: '../loader/emojiLess',
},
],
loaders: [
{
test: /\.less$/,
include: path.resolve(__dirname, 'css'),
loader: 'css!autoprefixer!less',
},
{
test: path => /\.js$/.test(path) && !/\.test\.js$/.test(path),
exclude: /node_modules/,
loaders: ['react-hot', 'babel'],
},
{
test: /\.svg$/,
loader: 'url?limit=1000000',
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.DOMAIN': JSON.stringify(process.env.DOMAIN),
'process.env.EMBED_ORIGIN': JSON.stringify(process.env.EMBED_ORIGIN || 'http://localhost:8080/embed'),
'process.env.HEIM_ORIGIN': JSON.stringify(process.env.HEIM_ORIGIN || 'http://localhost:8080'),
}),
new StaticSiteGeneratorPlugin('main', ['/', '/embed/']),
],
}
if (process.env.NODE_ENV === 'production') {
const lessLoader = config.module.loaders[0]
lessLoader.loader = ExtractTextPlugin.extract(lessLoader.loader)
config.plugins.push(new ExtractTextPlugin('main.[contenthash].css'))
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {warnings: false},
}))
config.plugins.push(new webpack.optimize.DedupePlugin())
}
export default config