/** * 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 } }, ], }, { // styles.scss @imports Bootstrap + bootstrap-icons from node_modules — webpack // now compiles it (replaces gulp's `mixin` task). quietDeps silences Bootstrap's // internal sass deprecation noise; url:false keeps the bootstrap-icons font path. test: /\.scss$/, use: [ MiniCssExtractPlugin.loader, { loader: 'css-loader', options: { url: false, import: false } }, { loader: 'sass-loader', options: { implementation: require('sass'), sassOptions: { quietDeps: true }, }, }, ], }, ], }, 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, }), ], };