Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Webpack plugin to ignore JS and PHP asset files when stylesheet used as entrypoint #6078

Merged
merged 7 commits into from
Apr 21, 2021
5 changes: 4 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ const styles = {
const entries = {};
const dir = './assets/css/src';
fs.readdirSync( dir ).forEach( ( fileName ) => {
entries[ fileName.replace( /\.[^/.]+$/, '' ) ] = `${ dir }/${ fileName }`;
const fullPath = `${ dir }/${ fileName }`;
if ( ! fs.lstatSync( fullPath ).isDirectory() ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this to ignore directories in assets/css/src, i.e. only root files in that directory will be used as entries.

entries[ fileName.replace( /\.[^/.]+$/, '' ) ] = fullPath;
}
} );

return entries;
Expand Down