|
| 1 | +/** |
| 2 | + * Block editor config webpack partial. |
| 3 | + * |
| 4 | + * Site Kit by Google, Copyright 2024 Google LLC |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +/** |
| 20 | + * External dependencies |
| 21 | + */ |
| 22 | +const CircularDependencyPlugin = require( 'circular-dependency-plugin' ); |
| 23 | +const ESLintPlugin = require( 'eslint-webpack-plugin' ); |
| 24 | +const ManifestPlugin = require( 'webpack-manifest-plugin' ); |
| 25 | +const WebpackBar = require( 'webpackbar' ); |
| 26 | + |
| 27 | +/** |
| 28 | + * Internal dependencies |
| 29 | + */ |
| 30 | +const { |
| 31 | + rootDir, |
| 32 | + manifestArgs, |
| 33 | + resolve, |
| 34 | + gutenbergExternals, |
| 35 | + createRules, |
| 36 | + createMinimizerRules, |
| 37 | +} = require( './common' ); |
| 38 | + |
| 39 | +module.exports = ( mode ) => ( { |
| 40 | + entry: { |
| 41 | + 'googlesitekit-reader-revenue-manager-block-editor': |
| 42 | + './assets/js/googlesitekit-reader-revenue-manager-block-editor.js', |
| 43 | + }, |
| 44 | + externals: gutenbergExternals, |
| 45 | + output: { |
| 46 | + filename: |
| 47 | + mode === 'production' ? '[name]-[contenthash].js' : '[name].js', |
| 48 | + path: rootDir + '/dist/assets/js', |
| 49 | + publicPath: '', |
| 50 | + }, |
| 51 | + module: { |
| 52 | + rules: createRules( mode ), |
| 53 | + }, |
| 54 | + plugins: [ |
| 55 | + new WebpackBar( { |
| 56 | + name: 'Block Editor Entry Points', |
| 57 | + color: '#deff13', |
| 58 | + } ), |
| 59 | + new CircularDependencyPlugin( { |
| 60 | + exclude: /node_modules/, |
| 61 | + failOnError: true, |
| 62 | + allowAsyncCycles: false, |
| 63 | + cwd: process.cwd(), |
| 64 | + } ), |
| 65 | + new ManifestPlugin( { |
| 66 | + ...manifestArgs( mode ), |
| 67 | + filter( file ) { |
| 68 | + return ( file.name || '' ).match( /\.js$/ ); |
| 69 | + }, |
| 70 | + } ), |
| 71 | + new ESLintPlugin( { |
| 72 | + emitError: true, |
| 73 | + emitWarning: true, |
| 74 | + failOnError: true, |
| 75 | + } ), |
| 76 | + ], |
| 77 | + optimization: { |
| 78 | + minimizer: createMinimizerRules( mode ), |
| 79 | + }, |
| 80 | + resolve, |
| 81 | +} ); |
0 commit comments