-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
50 lines (47 loc) · 1.15 KB
/
Copy pathwebpack.config.js
File metadata and controls
50 lines (47 loc) · 1.15 KB
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
const defaults = require( '@wordpress/scripts/config/webpack.config' );
const { getWebpackEntryPoints } = require( '@wordpress/scripts/utils/config' );
const I18nLoaderWebpackPlugin = require( '@automattic/i18n-loader-webpack-plugin' );
const path = require( 'path' );
const config = { ...defaults };
// Add server only for development mode and not for production.
if ( 'production' !== process.env.NODE_ENV ) {
config.devServer = {
devMiddleware: {
writeToDisk: true,
},
allowedHosts: 'all',
host: 'localhost',
port: 8887,
proxy: {
'/build': {
pathRewrite: {
'^/build': '',
},
},
},
};
}
module.exports = {
...config,
entry: {
...getWebpackEntryPoints(), // For blocks.
'i18n-loader': './tools/i18n-loader.ts',
index: './src/index.tsx', // For admin scripts.
},
plugins: [
...defaults.plugins,
new I18nLoaderWebpackPlugin( {
textdomain: 'wp-plugin-kit',
loaderModule: 'wpPluginKitI18nLoader',
} ),
],
resolve: {
alias: {
'@': path.resolve( __dirname, './src' ),
},
extensions: [ '.tsx', '.ts', '.jsx', '.js' ],
},
externals: {
wpPluginKitI18nLoader: [ 'window', 'wpPluginKitI18nLoader' ],
},
};