From 938a7c1aa2c7aea819786c7beb8a20f024cce17e Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 9 Feb 2018 16:30:57 -0500 Subject: [PATCH] Use basename on rawRequest for generating output directory directory of resolved request is not sufficient because the resolved file of WordPress dependencies is within the `build-module` directory and would output as such. Instead format in such a way that we can call basename on the _raw_ requested path (e.g. `./editor` -> "editor", `./node_modules/@wordpress/hooks" -> "hooks") --- webpack.config.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 721e1f6a19c231..4915c6c0534bcc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,11 +5,11 @@ const webpack = require( 'webpack' ); const ExtractTextPlugin = require( 'extract-text-webpack-plugin' ); const WebpackRTLPlugin = require( 'webpack-rtl-plugin' ); const { reduce, escapeRegExp, castArray, get } = require( 'lodash' ); -const { basename, dirname } = require( 'path' ); +const { basename } = require( 'path' ); // Main CSS loader for everything but blocks.. const mainCSSExtractTextPlugin = new ExtractTextPlugin( { - filename: './[dir]/build/style.css', + filename: './[basename]/build/style.css', } ); // CSS loader for styles specific to block editing. @@ -130,7 +130,7 @@ const config = { entryPointNames.reduce( ( memo, entryPoint ) => { entryPoint = castArray( entryPoint ); const [ name, path = name ] = entryPoint; - memo[ name ] = `./${ path }/index.js`; + memo[ name ] = `./${ path }`; return memo; }, {} ), packageNames.reduce( ( memo, packageName ) => { @@ -139,7 +139,7 @@ const config = { }, {} ) ), output: { - filename: '[dir]/build/index.js', + filename: '[basename]/build/index.js', path: __dirname, library: [ 'wp', '[name]' ], libraryTarget: 'this', @@ -202,10 +202,10 @@ const config = { debug: process.env.NODE_ENV !== 'production', } ), new CustomTemplatedPathPlugin( { - dir( path, data ) { - const request = get( data, [ 'chunk', 'entryModule', 'request' ] ); - if ( request ) { - return basename( dirname( request ) ); + basename( path, data ) { + const rawRequest = get( data, [ 'chunk', 'entryModule', 'rawRequest' ] ); + if ( rawRequest ) { + return basename( rawRequest ); } return path;