forked from ysun/scratch3.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
75 lines (74 loc) · 2.04 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
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
module.exports = {
entry: {
lib: ['react', 'react-dom'],
gui: './app/index.jsx'
},
output: {
path: path.resolve(__dirname, 'nwjs/app'),
filename: '[name].js'
},
devServer: {
contentBase: path.resolve(__dirname, 'nwjs/app'),
host: '0.0.0.0'
},
target: 'node-webkit',
module: {
externals: {
React: 'react',
ReactDOM: 'react-dom'
},
loaders: [{
test: /\.jsx?$/,
loader: 'babel-loader',
include: path.resolve(__dirname, 'app'),
query: {
plugins: ['transform-object-rest-spread'],
presets: ['es2015', 'react']
}
},
{
test: /\.svg$/,
loader: 'svg-url-loader?noquotes'
},
{
test : /\.(ttf|eot|png|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
loader : 'file-loader'
},
{
test: /\.json$/,
loader: 'json-loader'
},{
test: /\.css$/, // Only .css files
loader: 'style!css' // Run both loaders
}]
},
plugins: [
new webpack.DefinePlugin({
'process.env.BASE_PATH': '"' + (process.env.BASE_PATH || '/') + '"'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'lib',
filename: 'lib.min.js'
}),
new HtmlWebpackPlugin({
title: 'KittenBlock',
template: 'index.html'
}),
new CopyWebpackPlugin([{
from: 'scratch-blocks/media',
to: 'media'
}])
].concat(process.env.NODE_ENV === 'production' ? [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
compress: {
warnings: false
}
})
] : [])
};