Skip to content

Commit cbc0c61

Browse files
committed
Implement frontend build for superagent and fetch (now default) versions
1 parent 8e7625a commit cbc0c61

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

webpack.config.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@
33
const { join } = require( 'path' );
44

55
module.exports = {
6-
entry: './wpapi.js',
6+
entry: {
7+
wpapi: './fetch',
8+
'wpapi-superagent': './superagent',
9+
},
10+
11+
// Use browser builtins instead of Node packages where appropriate.
12+
externals: {
13+
'isomorphic-unfetch': 'fetch',
14+
'form-data': 'FormData',
15+
},
16+
17+
node: {
18+
fs: 'empty',
19+
},
720

821
mode: 'development',
922

@@ -21,7 +34,7 @@ module.exports = {
2134

2235
output: {
2336
path: join( process.cwd(), 'browser' ),
24-
filename: 'wpapi.js',
37+
filename: '[name].js',
2538
library: 'WPAPI',
2639
libraryTarget: 'umd',
2740
},
@@ -30,7 +43,7 @@ module.exports = {
3043
rules: [
3144
{
3245
test: /\.js$/,
33-
exclude: /(node_modules|bower_components)/,
46+
exclude: /(node_modules)/,
3447
loader: require.resolve( 'babel-loader' ),
3548
options: {
3649
presets: [ '@babel/preset-env' ],

webpack.config.minified.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414

1515
output: {
1616
...config.output,
17-
filename: 'wpapi.min.js',
17+
filename: '[name].min.js',
1818
},
1919

2020
optimization: {

0 commit comments

Comments
 (0)