-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
80 lines (76 loc) · 2.02 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
'use strict'
const webpack = require('webpack')
const path = require('path')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const isProd = process.env.NODE_ENV === 'production'
const isDev = !isProd
const config = module.exports = {
entry: {
plugin: './src/plugin.js',
main_tab: './src/main_tab.jsx'
},
output: {
path: `${__dirname}/dist/dashboard-resources`,
publicPath: '/',
filename: '[name].js'
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}, {
test: /\.(png|jpg|jpeg|gif|svg)$/,
// inline base64 URLs for <= 8k images, direct URLs for the rest
loader: 'url-loader?limit=8192'
}, {
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
loader: 'url-loader?mimetype=application/font-woff'
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/,
loader: 'file-loader?name=[name].[ext]'
}]
},
resolve: {
alias: {
// prevent multiple reacts loaded from various dependencies
'react': path.join(__dirname, 'node_modules', 'react')
},
extensions: ['', '.js', '.jsx']
},
plugins: [
new CleanWebpackPlugin(['dist']),
new CopyWebpackPlugin([
{ from: 'static/dashboard.json', to: '../' },
{ from: 'static/html' },
{ from: 'static/css' },
{ from: 'static/fonts' }
]),
new webpack.ProvidePlugin({
// Bootstrap's JavaScript implicitly requires jQuery global
jQuery: 'jquery'
}),
new webpack.DefinePlugin({
'__DEV__': JSON.stringify(isDev)
})
]
}
if (isProd) {
// emit source map for each generated chunk
config.devtool = 'source-map'
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
minimize: true
})
)
}