-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
84 lines (81 loc) · 2.15 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
81
82
83
84
const path = require('path');
const webpack = require('webpack');
const assign = require('webpack-config-assign');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = function webpackConfig({ environment = 'production' } = {}) {
const base = {
devtool: 'source-map',
entry: {
bundle: ['./src/index'],
vendor: ['react', 'react-dom', 'glamorous', 'buble', 'codemirror']
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'dist')
},
resolve: {
alias: {
assets: path.join(__dirname, 'assets'),
components: path.join(__dirname, 'src/components'),
style: path.join(__dirname, 'src/style'),
utils: path.join(__dirname, 'src/utils')
},
extensions: ['.js', '.ts', '.tsx', '.json', '.']
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
use: 'source-map-loader'
},
{
test: /\.tsx?$/,
use: 'awesome-typescript-loader',
include: [path.join(__dirname, 'src')],
exclude: [path.join(__dirname, 'src/Worker')]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
include: [path.join(__dirname, 'node_modules')]
},
{
test: /\.html$/,
use: ['html-loader']
},
{
test: /manifest\.json$/,
use: ['file-loader']
},
{
test: /\.js$/,
use: ['raw-loader'],
include: [path.join(__dirname, 'src/snippets')]
},
{
test: /\.ts$/,
use: ['worker-loader', 'awesome-typescript-loader'],
include: path.join(__dirname, 'src/Worker')
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: 'body',
template: 'src/index.html'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(environment)
})
],
externals: {
React: 'react',
ReactDOM: 'react-dom'
},
stats: {
children: false
}
};
return assign(base, require(`./webpack.config.${environment}`));
};