-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
92 lines (84 loc) · 2.4 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const path = require( 'path' );
const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' );
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
module.exports = [
{
entry: {
// Video block
'block-editor/blocks/video/index': './src/client/block-editor/blocks/video/index.ts',
'block-editor/blocks/video/view': './src/client/block-editor/blocks/video/view.ts',
'lib/token-bridge': './src/client/lib/token-bridge/index.ts',
'lib/player-bridge': './src/client/lib/player-bridge/index.ts',
'lib/videopress-token-bridge': './src/client/lib/videopress-token-bridge.js',
// VideoPress dashboard page
'admin/index': './src/client/admin/index.js',
// Block editor extensions
'block-editor/index': './src/client/block-editor/index.ts',
// Divi editor extensions
'divi-editor/index': './src/client/divi-editor/index.js',
},
mode: jetpackWebpackConfig.mode,
devtool: jetpackWebpackConfig.devtool,
output: {
...jetpackWebpackConfig.output,
path: path.resolve( './build' ),
},
optimization: {
...jetpackWebpackConfig.optimization,
},
resolve: {
...jetpackWebpackConfig.resolve,
},
node: false,
plugins: [
...jetpackWebpackConfig.StandardPlugins(),
new CopyWebpackPlugin( {
patterns: [
{
context: 'src/client/block-editor/blocks',
from: './*/block.json',
to: './block-editor/blocks/[path]/[name].json',
},
{
from: 'src/client/block-editor/extensions/index.json',
to: './block-editor/extensions/index.json',
},
],
} ),
],
module: {
strictExportPresence: true,
rules: [
// Transpile JavaScript
jetpackWebpackConfig.TranspileRule( {
exclude: /node_modules\//,
} ),
// Transpile @automattic/jetpack-* in node_modules too.
jetpackWebpackConfig.TranspileRule( {
includeNodeModules: [ '@automattic/jetpack-' ],
} ),
// Handle CSS.
jetpackWebpackConfig.CssRule( {
extensions: [ 'css', 'sass', 'scss' ],
extraLoaders: [
{
loader: 'postcss-loader',
options: {
postcssOptions: { config: path.join( __dirname, 'postcss.config.js' ) },
},
},
'sass-loader',
],
} ),
// Handle images.
jetpackWebpackConfig.FileRule(),
],
},
externals: {
...jetpackWebpackConfig.externals,
jetpackConfig: JSON.stringify( {
consumer_slug: 'jetpack-videopress',
} ),
},
},
];