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

Run [npm run theme] after successful webpack build so sprites and pot files are built. #586

Closed
wants to merge 1 commit into from

Conversation

aubreypwd
Copy link
Contributor

@aubreypwd aubreypwd commented Feb 27, 2021

This hooks into Webpack, and when a build is emitted, we run npm run theme so that pot files and sprites are re-generated into the build folder.

Closes #583

DESCRIPTION

image

This solves #583 by ensuring that the WebPack build runs the commands we use to built the sprite.svg and languages/*.pot files.

The issue in #583 is that when you run npm run theme theme:icons is ran which generates the build/images/icons/sprite.svg file, but then on npm run start Webpack's CopyWebpackPlugin plugin essentially deletes build/images and copies src/images/** over. Ran in this order, the build/images/icons/sprite.svg file is deleted in the process and never generated again.

This solution fixes this by having Webpack run npm run theme after CopyWebpackPlugin plugin runs to re-generate the build/images/icons/sprite.svg file.

It also fixes another underlying (and related issue) where the POT files in build/languages/*.pot are built once when npm run them runs on postinstall but are never regenerated again. Additionally this fix fixes that too since pot files are generated to the build/languages/ folder on npm run theme.

STEPS TO VERIFY

Running node@12 clone the directory and run npm i then run npm run start and e.g. modify an SVG in in src/images/icon and notice that unlike in #583 the build/images/sprite.svg file is no longer deleted on npm run start.

DOCUMENTATION

Will this pull request require updating the wd_s wiki?

I don't think so.

This hooks into Webpack, and when a build is emitted, we run `npm run theme` so that pot files and sprites are re-generated into the build folder.
@aubreypwd aubreypwd self-assigned this Feb 27, 2021
@aubreypwd aubreypwd added the bug label Feb 27, 2021
@coreymcollins
Copy link
Contributor

I think we'll need to find a more graceful solution to this. In my testing, saving a small change to a Sass partial is resulting in build times of 15+ seconds while running npm run start, compared to the current main branch which is around 4 seconds.

@coreymcollins
Copy link
Contributor

We don't need to run the POT and SVG processes every time. Ideally, while running npm run start we'd be listening for changes to PHP files and SVG files and run those processes as needed, but right now everything runs whenever any change to any file is made.

@coreymcollins coreymcollins mentioned this pull request Mar 4, 2021
3 tasks
@aubreypwd
Copy link
Contributor Author

So it sounds like what you want to do is only run POT stuff when POT files change, and SVG stuff with SVG files change. I think we might be able to do that.

@coreymcollins
Copy link
Contributor

Not sure if you've had a chance to look at #587, but I think we've solved the SVG issue there as part of some other add-ons/improvements.

@gregrickaby gregrickaby deleted the issue/aubreypwd/583 branch April 1, 2021 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sprite.svg not generated during npm run start
2 participants