It is just a test to see whether the block editor loads, because it is not so easy: it requires specific versions of the dependencies, or it will fail with some idiotic syntax errors after failing to “convert” the libraries code. And it is impossible to use with Vite: it refuses to accept incorrect SCSS code, that WordPress has a lot of, with things as `::after::after`. What i did is write my package.json, replace the generated lock file with the one from Isolated Block Editor, and npm install again, to “clean up” the lock file.
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const TerserJSPlugin = require('terser-webpack-plugin');
|
|
|
|
const config = {
|
|
entry: {
|
|
editor: './editor/index.js',
|
|
},
|
|
output: {
|
|
filename: '[name].js',
|
|
path: path.resolve(__dirname, 'web/static'),
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.(js|mjs)$/,
|
|
exclude: /node_modules/,
|
|
loader: 'babel-loader',
|
|
},
|
|
{
|
|
test: /\.scss|\.css$/,
|
|
use: [
|
|
{
|
|
loader: MiniCssExtractPlugin.loader,
|
|
},
|
|
'css-loader',
|
|
'sass-loader',
|
|
],
|
|
},
|
|
],
|
|
},
|
|
externals: {
|
|
react: 'React',
|
|
'react-dom': 'ReactDOM',
|
|
},
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
'process.env': {NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')},
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].css',
|
|
}),
|
|
],
|
|
optimization: {
|
|
minimizer: [new TerserJSPlugin()],
|
|
},
|
|
};
|
|
|
|
module.exports = config;
|