| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /**
- * Build config for the v0.5.0 FSE migration (@wordpress/scripts + webpack).
- *
- * Phase 1 (CSS): webpack now produces the site-wide stylesheet `v4-style.min.css`
- * (the old gulp `build` task). The legacy gulp pipeline still handles the JS bundles
- * for now — those migrate later, as their jQuery-era behaviors get modernized during
- * the template phases (see _claude/notes/upgrade-plan.md).
- *
- * Output layout (output.path = theme root so nothing escapes it):
- * - JS → build/[name].js (src/index.js seed; block view scripts later)
- * - v4-style → v4-style.min.css (theme root — keeps the `style-min` enqueue + font url()s valid)
- * - other CSS → build/[name].css
- */
- const path = require('path');
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
- const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
- module.exports = {
- entry: {
- index: './src/index.js',
- // Reproduces gulp `build` → v4-style.min.css (concat of the 5 CSS sources, in order).
- 'v4-style': './src/legacy-style.js',
- },
- output: {
- path: path.resolve(__dirname), // theme root
- filename: 'build/[name].js', // JS bundles live under build/
- clean: false, // NEVER clean — output.path is the theme root
- },
- module: {
- rules: [
- {
- test: /\.js$/,
- exclude: /node_modules/,
- use: { loader: 'babel-loader' },
- },
- {
- test: /\.css$/,
- use: [
- MiniCssExtractPlugin.loader,
- // url:false / import:false → leave url() + @import untouched (gulp-concat parity,
- // so the relative `fonts/…` paths keep resolving from the theme root).
- { loader: 'css-loader', options: { url: false, import: false } },
- ],
- },
- ],
- },
- optimization: {
- // '...' keeps webpack's default JS minifier (terser); add CSS minification.
- minimizer: [
- '...',
- // discardComments.removeAll matches the old gulp clean-css (specialComments:0).
- new CssMinimizerPlugin({
- minimizerOptions: { preset: ['default', { discardComments: { removeAll: true } }] },
- }),
- ],
- },
- plugins: [
- new MiniCssExtractPlugin({
- filename: ({ chunk }) =>
- chunk.name === 'v4-style' ? 'v4-style.min.css' : 'build/[name].css',
- }),
- new BrowserSyncPlugin({
- host: 'daw.stu',
- port: 3030,
- proxy: 'https://daw.stu',
- https: {
- key: '/opt/homebrew/etc/httpd/ssl/daw.stu-key.pem',
- cert: '/opt/homebrew/etc/httpd/ssl/daw.stu-cert.pem',
- },
- files: [
- './**/*.php',
- './src/**/*.js',
- './src/**/*.css',
- './templates/**/*.html',
- './parts/**/*.html',
- './patterns/**/*.php',
- './theme.json',
- ],
- ignore: ['node_modules', 'build', 'js/v4-*', '*.min.*'],
- open: 'external',
- reloadDelay: 50,
- injectChanges: true,
- notify: false,
- }),
- ],
- };
|