-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.babel.js
93 lines (89 loc) · 2.39 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
const isProd = process.env.NODE_ENV === 'production';
const minifiedExt = isProd ? '.min' : '';
const webpackConfig = {
entry: [
'./src/index.js',
],
output: {
filename: `js/GenomePlot${minifiedExt}.js`,
path: path.resolve(__dirname, isProd ? 'dist' : 'build'),
},
module: {
rules: [
{
test: require.resolve('./vendor/dat-gui/dat.gui-0.5.1-plus.min.js'),
use: 'exports-loader?dat',
},
{
test: /\.js$/,
exclude: [/node_modules/, /vendor/],
use: 'babel-loader',
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
}),
},
{
test: /\.(jpe?g|gif|png)$/,
loader: 'file-loader?emitFile=false&name=[path][name].[ext]',
},
{
test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?publicPath=../&name=fonts/[name].[ext]',
},
],
},
devtool: isProd ? false : 'inline-source-map',
resolve: {
extensions: ['.js'],
},
devServer: {
hot: true,
port: 8000,
watchContentBase: true,
contentBase: './public',
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
d3: 'd3',
}),
// from https://stackoverflow.com/questions/25384360/
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({ filename: 'GenomePlot.html', template: 'public/GenomePlot.html' }),
new ExtractTextPlugin({ filename: `css/GenomePlot${minifiedExt}.css`, disable: !isProd }),
],
};
if (isProd)
{
// from: https://stackoverflow.com/a/41041580/1980846
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
pure_funcs: [
'console.log',
'console.debug',
'console.time',
'console.timeEnd',
'console.log.apply',
'console.debug.apply',
'console.time.apply',
'console.timeEnd.apply',
'console.verbose',
],
},
}));
}
export default webpackConfig;