-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
interactivity.js
91 lines (89 loc) · 2.05 KB
/
interactivity.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
/**
* External dependencies
*/
const { join } = require( 'path' );
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
/**
* WordPress dependencies
*/
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
/**
* Internal dependencies
*/
const { baseConfig, plugins } = require( './shared' );
module.exports = {
...baseConfig,
name: 'interactivity',
entry: {
index: `./packages/interactivity/src/index.js`,
router: `./packages/interactivity-router/src/index.js`,
navigation: './packages/block-library/src/navigation/view.js',
query: './packages/block-library/src/query/view.js',
image: './packages/block-library/src/image/view.js',
file: './packages/block-library/src/file/view.js',
search: './packages/block-library/src/search/view.js',
},
experiments: {
outputModule: true,
},
output: {
devtoolNamespace: 'wp',
filename: './build/interactivity/[name].min.js',
library: {
type: 'module',
},
path: join( __dirname, '..', '..' ),
environment: { module: true },
module: true,
chunkFormat: 'module',
},
resolve: {
extensions: [ '.js', '.ts', '.tsx' ],
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve( 'babel-loader' ),
options: {
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
'@babel/preset-typescript',
[
'@babel/preset-react',
{
runtime: 'automatic',
importSource: 'preact',
},
],
],
},
},
],
},
],
},
plugins: [
...plugins,
// TODO: Move it to a different Webpack file.
new CopyWebpackPlugin( {
patterns: [
{
from: './node_modules/es-module-shims/dist/es-module-shims.wasm.js',
to: './build/modules/importmap-polyfill.min.js',
},
],
} ),
new DependencyExtractionWebpackPlugin(),
],
watchOptions: {
ignored: [ '**/node_modules' ],
aggregateTimeout: 500,
},
};