const defaultConfig = require('@wordpress/scripts/config/webpack.config.js'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const path = require('path'); const fs = require('fs'); class MoveRtlStylePlugin { apply(compiler) { compiler.hooks.emit.tapAsync('MoveRtlStylePlugin', (compilation, callback) => { const assets = Object.keys(compilation.assets); assets.forEach((asset) => { if (asset.includes('rtl.css')) { const targetPath = path.join('assets/blocks/post-summary', path.basename(asset)); const content = compilation.assets[asset].source(); fs.mkdirSync(path.dirname(path.resolve(__dirname, targetPath)), { recursive: true }); fs.writeFileSync(path.resolve(__dirname, targetPath), content); // Remove the old asset delete compilation.assets[asset]; } }); callback(); }); } } module.exports = { ...defaultConfig, entry: { ...defaultConfig.entry(), 'post-summary': './assets/dev/blocks/post-summary/index.js', }, output: { ...defaultConfig.output, filename: 'post-summary/[name].js', }, plugins: [ ...defaultConfig.plugins.filter( (plugin) => !(plugin instanceof MiniCssExtractPlugin) ), new MiniCssExtractPlugin({ filename: 'post-summary/[name].css', }), new MoveRtlStylePlugin(), ], module: { rules: [ ...defaultConfig.module.rules, { test: /\.css$/, use: [ MiniCssExtractPlugin.loader, 'css-loader', { loader: 'postcss-loader', options: { postcssOptions: { plugins: [ require('autoprefixer'), require('rtlcss')(), // Generate RTL CSS ], }, }, }, ], }, ], }, };
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
assets | Folder | 0755 |
|
|
includes | Folder | 0755 |
|
|
languages | Folder | 0755 |
|
|
src | Folder | 0755 |
|
|
vendor | Folder | 0755 |
|
|
views | Folder | 0755 |
|
|
.editorconfig | File | 38.17 KB | 0644 |
|
CHANGELOG.md | File | 101.66 KB | 0644 |
|
CONTRIBUTING.md | File | 3.29 KB | 0644 |
|
gulpfile.js | File | 5.25 KB | 0644 |
|
license.txt | File | 34.98 KB | 0644 |
|
readme.txt | File | 9.78 KB | 0644 |
|
security.md | File | 339 B | 0644 |
|
webpack.config.js | File | 2.24 KB | 0644 |
|
wp-statistics.php | File | 1.04 KB | 0644 |
|