-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
66 lines (60 loc) · 1.44 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
/**
* External dependencies
*/
const path = require( 'path' );
const webpack = require( 'webpack' );
const ResolveEntryModulesPlugin = require( 'resolve-entry-modules-webpack-plugin' );
const glob = require( 'glob' );
const config = {
entry: './index.js',
output: {
filename: 'build/index.js',
path: __dirname,
library: 'phs',
libraryTarget: 'umd',
},
target: 'node',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: 'babel-loader',
},
],
},
plugins: [
new ResolveEntryModulesPlugin(),
new webpack.LoaderOptionsPlugin( {
minimize: process.env.NODE_ENV === 'production',
debug: process.env.NODE_ENV !== 'production',
} ),
new webpack.ProvidePlugin( {
createSchemaElement: path.join( __dirname, 'lib', 'jsx-handler.js' ),
} ),
new webpack.ProvidePlugin( {
FakeDOM: path.join( __dirname, 'lib', 'jsx-to-fake-dom.js' ),
} ),
],
stats: {
children: false,
},
};
switch ( process.env.NODE_ENV ) {
case 'production':
// TODO this causes "Error: Invalid schema tag name: t"
// config.plugins.push( new webpack.optimize.UglifyJsPlugin() );
break;
case 'test':
config.externals = [ require( 'webpack-node-externals' )() ];
config.output = {
filename: 'build/test.js',
path: __dirname,
};
config.entry = [ config.entry ];
config.entry = config.entry.concat( glob.sync( './test/*.js' ) );
break;
default:
config.devtool = 'source-map';
}
module.exports = config;