-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
93 lines (91 loc) · 2.59 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
85
86
87
88
89
90
91
92
93
'use strict';
const webpack = require('webpack');
const useCSSSourceMaps = (process.env.CSS_SOURCEMAPS === 'true');
const path = require('path');
module.exports = [
{
entry: {
client: ['webpack-dev-server/client?http://localhost:8080'],
index: ['./src/index.jsx', 'webpack/hot/only-dev-server'],
component_library: ['webpack/hot/only-dev-server', './src/component_library.jsx'],
illustrator: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./src/illustrator.jsx'
]
},
resolve: {
root: [path.resolve(__dirname, 'src')],
extensions: ['', '.js', '.jsx']
},
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: '[name].js'
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: [
'react-hot',
'babel?presets[]=react,presets[]=es2015,plugins[]=syntax-trailing-function-commas'
]
},{
test: /\.css$/,
exclude: /node_modules/,
loaders: [
'style',
// Enabling source maps for the css loader moves the style
// definitions into object urls which means we cannot use relative
// paths (see links below).
// Because we need to use relative paths in the Electron app (we have
// no server running) we have to disable source maps for it.
// https://github.com/webpack/style-loader#recommended-configuration
// https://github.com/webpack/style-loader/issues/55
useCSSSourceMaps ? 'css?modules&sourceMap' : 'css?modules'
]
}]
},
devServer: {
contentBase: './dist',
hot: true
},
plugins: [
new webpack.ProvidePlugin({
$ : "jquery",
jQuery : "jquery",
"window.jQuery" : "jquery",
"root.jQuery" : "jquery"
}),
new webpack.HotModuleReplacementPlugin()
],
devtool: 'source-map'
},
{
name: 'server',
entry: ['./src/illustrator.jsx'],
target: 'node',
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015'],
plugins: ['syntax-trailing-function-commas']
}
}]
},
resolve: {
root: [path.resolve(__dirname, 'src')],
extensions: ['', '.js', '.jsx']
},
output: {
path: __dirname + '/server',
publicPath: '/',
filename: 'illustrator.generated.js',
libraryTarget: "commonjs2"
}
}
];