Make WordPress Core

Changeset 54307


Ignore:
Timestamp:
09/26/2022 11:20:43 AM (17 months ago)
Author:
gziolo
Message:

Tools: Fix running build scripts on Windows does not generate CSS files for blocks

Starting with WordPress 6.0, when running npm run build or npm run build:dev, no CSS files were generated for the blocks within wp-includes/blocks/**.

Props wildworks, clorith, sergeybiryukov.
Fixes #56616.

Location:
trunk/tools/webpack
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/webpack/blocks.js

    r54257 r54307  
    44const { DefinePlugin } = require( 'webpack' );
    55const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
    6 const { join } = require( 'path' );
    76
    87/**
     
    1413 * Internal dependencies
    1514 */
    16 const { stylesTransform, baseConfig, baseDir } = require( './shared' );
     15const { normalizeJoin, stylesTransform, baseConfig, baseDir } = require( './shared' );
    1716
    1817module.exports = function( env = { environment: 'production', watch: false, buildTarget: false } ) {
     
    132131
    133132    const blockPHPCopies = Object.keys( blockPHPFiles ).map( ( filename ) => ( {
    134         from: join( baseDir, `node_modules/@wordpress/${ filename }` ),
    135         to: join( baseDir, `src/${ blockPHPFiles[ filename ] }` ),
     133        from: normalizeJoin(baseDir, `node_modules/@wordpress/${ filename }` ),
     134        to: normalizeJoin(baseDir, `src/${ blockPHPFiles[ filename ] }` ),
    136135    } ) );
    137136
    138137    const blockMetadataCopies = Object.keys( blockMetadataFiles ).map( ( filename ) => ( {
    139         from: join( baseDir, `node_modules/@wordpress/${ filename }` ),
    140         to: join( baseDir, `src/${ blockMetadataFiles[ filename ] }` ),
     138        from: normalizeJoin(baseDir, `node_modules/@wordpress/${ filename }` ),
     139        to: normalizeJoin(baseDir, `src/${ blockMetadataFiles[ filename ] }` ),
    141140    } ) );
    142141
    143142    const blockStylesheetCopies = blockFolders.map( ( blockName ) => ( {
    144         from: join( baseDir, `node_modules/@wordpress/block-library/build-style/${ blockName }/*.css` ),
    145         to: join( baseDir, `${ buildTarget }/blocks/${ blockName }/[name]${ suffix }.css` ),
     143        from: normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-style/${ blockName }/*.css` ),
     144        to: normalizeJoin(baseDir, `${ buildTarget }/blocks/${ blockName }/[name]${ suffix }.css` ),
    146145        transform: stylesTransform( mode ),
    147146        noErrorOnMissing: true,
     
    151150        ...baseConfig( env ),
    152151        entry: {
    153             'file/view': join( baseDir, `node_modules/@wordpress/block-library/build-module/file/view` ),
    154             'navigation/view': join( baseDir, `node_modules/@wordpress/block-library/build-module/navigation/view` ),
    155             'navigation/view-modal': join( baseDir, `node_modules/@wordpress/block-library/build-module/navigation/view-modal` ),
     152            'file/view': normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-module/file/view` ),
     153            'navigation/view': normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-module/navigation/view` ),
     154            'navigation/view-modal': normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-module/navigation/view-modal` ),
    156155        },
    157156        output: {
    158157            devtoolNamespace: 'wp',
    159158            filename: `[name]${ suffix }.js`,
    160             path: join( baseDir, `${ buildTarget }/blocks` ),
     159            path: normalizeJoin(baseDir, `${ buildTarget }/blocks` ),
    161160        },
    162161        plugins: [
  • trunk/tools/webpack/packages.js

    r54289 r54307  
    66const LiveReloadPlugin = require( 'webpack-livereload-plugin' );
    77const UglifyJS = require( 'uglify-js' );
    8 const { join } = require( 'path' );
    98
    109/**
     
    1918 * Internal dependencies
    2019 */
    21 const { stylesTransform, baseConfig, baseDir } = require( './shared' );
     20const { normalizeJoin, stylesTransform, baseConfig, baseDir } = require( './shared' );
    2221const { dependencies } = require( '../../package' );
    2322
     
    4342function mapVendorCopies( vendors, buildTarget ) {
    4443    return Object.keys( vendors ).map( ( filename ) => ( {
    45         from: join( baseDir, `node_modules/${ vendors[ filename ] }` ),
    46         to: join( baseDir, `${ buildTarget }/js/dist/vendor/${ filename }` ),
     44        from: normalizeJoin(baseDir, `node_modules/${ vendors[ filename ] }` ),
     45        to: normalizeJoin(baseDir, `${ buildTarget }/js/dist/vendor/${ filename }` ),
    4746    } ) );
    4847}
     
    116115
    117116    let cssCopies = packages.map( ( packageName ) => ( {
    118         from: join( baseDir, `node_modules/@wordpress/${ packageName }/build-style/*.css` ),
    119         to: join( baseDir, `${ buildTarget }/css/dist/${ packageName }/[name]${ suffix }.css` ),
     117        from: normalizeJoin(baseDir, `node_modules/@wordpress/${ packageName }/build-style/*.css` ),
     118        to: normalizeJoin(baseDir, `${ buildTarget }/css/dist/${ packageName }/[name]${ suffix }.css` ),
    120119        transform: stylesTransform( mode ),
    121120        noErrorOnMissing: true,
     
    123122
    124123    const phpCopies = Object.keys( phpFiles ).map( ( filename ) => ( {
    125         from: join( baseDir, `node_modules/@wordpress/${ filename }` ),
    126         to: join( baseDir, `src/${ phpFiles[ filename ] }` ),
     124        from: normalizeJoin(baseDir, `node_modules/@wordpress/${ filename }` ),
     125        to: normalizeJoin(baseDir, `src/${ phpFiles[ filename ] }` ),
    127126    } ) );
    128127
     
    131130        entry: packages.reduce( ( memo, packageName ) => {
    132131            memo[ packageName ] = {
    133                 import: join( baseDir, `node_modules/@wordpress/${ packageName }` ),
     132                import: normalizeJoin(baseDir, `node_modules/@wordpress/${ packageName }` ),
    134133                library: {
    135134                    name: [ 'wp', camelCaseDash( packageName ) ],
     
    146145            devtoolNamespace: 'wp',
    147146            filename: `[name]${ suffix }.js`,
    148             path: join( baseDir, `${ buildTarget }/js/dist` ),
     147            path: normalizeJoin(baseDir, `${ buildTarget }/js/dist` ),
    149148        },
    150149        plugins: [
  • trunk/tools/webpack/shared.js

    r53135 r54307  
    7070};
    7171
     72const normalizeJoin = ( ...paths ) => join( ...paths ).replace( /\\/g, '/' );
     73
     74
    7275module.exports = {
    7376    baseDir,
    7477    baseConfig,
     78    normalizeJoin,
    7579    stylesTransform,
    7680};
Note: See TracChangeset for help on using the changeset viewer.