-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
63 lines (54 loc) · 1.55 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
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: [
'./embed.js',
],
output: {
filename: '[name].[hash].js',
path: path.join(__dirname, 'build'),
libraryTarget: 'umd',
},
devtool: 'source-map',
module: {
preLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['eslint'],
},
],
loaders: [
{
test: /\.less$/,
exclude: /node_modules/,
loader: 'css!less',
},
{
test: path => /\.js$/.test(path) && !/\.test\.js$/.test(path),
exclude: /node_modules/,
loaders: ['babel'],
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.DOMAIN': JSON.stringify(process.env.EMBED_ORIGIN || 'localhost'),
'process.env.HEIM_ORIGIN': JSON.stringify(process.env.HEIM_ORIGIN || 'http://localhost:8080'),
}),
new StaticSiteGeneratorPlugin('main', ['/']),
],
}
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