Skip to content

Commit

Permalink
Fix scripts output relative filepath (#53)
Browse files Browse the repository at this point in the history
Handle scripts output with relative paths under `dist/js` similar to
styles task.

Fixes #52
  • Loading branch information
cr0ybot authored Oct 29, 2023
1 parent 90b83e4 commit cbb30d8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Task: scripts.
*/

const { extname } = require( 'path' );

// External
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
const dedupe = require( 'gulp-dedupe' );
Expand Down Expand Up @@ -61,7 +63,14 @@ module.exports = {
.pipe( filterEntries )
.pipe( logFiles( { task: 'scripts', title: 'entry:' } ) )
// Convert into named entrypoints for WebPack.
.pipe( named() )
.pipe(
named( ( file ) => {
// Remove the glob base (everything before '*') and extension but keep the relative path.
return file.path
.replace( file.base, '' )
.replace( extname( file.path ), '' );
} )
)
// TODO: webpack errors are displayed twice.
.pipe( webpackStream( webpackConfig, webpack ) )
.pipe( gulp.dest( dest ) )
Expand Down

0 comments on commit cbb30d8

Please sign in to comment.