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
Use Webpack Encore #6823
base: master
Are you sure you want to change the base?
Use Webpack Encore #6823
Conversation
72086c1
to
408e0fb
Compare
408e0fb
to
60229db
Compare
60229db
to
a9ba80e
Compare
Managed to find a solution! 🎉 |
"useBuiltIns": "usage", | ||
"corejs": "3.23" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to match the Webpack Encore Bundle recipe, see https://github.com/symfony/recipes/blob/main/symfony/webpack-encore-bundle/1.10/webpack.config.js#L55-L56
@@ -59,3 +59,5 @@ specialexport.json | |||
|
|||
# Custom CSS file | |||
web/custom.css | |||
|
|||
yarn-error.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to match the Webpack Encore Bundle recipe, see https://github.com/symfony/recipes/blob/main/symfony/webpack-encore-bundle/1.10/manifest.json#L16
@@ -58,6 +60,7 @@ | |||
"postcss": "^8.4.27", | |||
"postcss-loader": "^7.3.3", | |||
"postcss-scss": "^4.0.6", | |||
"regenerator-runtime": "^0.14.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to match the Webpack Encore Bundle recipe, see https://github.com/symfony/recipes/blob/main/symfony/webpack-encore-bundle/1.10/package.json#L9
"webpack-manifest-plugin": "^5.0.0", | ||
"webpack-merge": "^5.9.0" | ||
"webpack-merge": "^5.9.0", | ||
"webpack-notifier": "^1.15.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to match the Webpack Encore Bundle recipe, see https://github.com/symfony/recipes/blob/main/symfony/webpack-encore-bundle/1.10/package.json#L12
"autoprefixer": "^10.4.14", | ||
"babel-loader": "^9.1.3", | ||
"core-js": "^3.32.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to match the Webpack Encore Bundle recipe, see https://github.com/symfony/recipes/blob/main/symfony/webpack-encore-bundle/1.10/package.json#L8
@@ -70,9 +73,9 @@ | |||
"url-loader": "^4.1.1", | |||
"webpack": "^5.88.2", | |||
"webpack-cli": "^5.1.4", | |||
"webpack-dev-server": "^4.15.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will still be installed as a transitive dependency
module.exports = { | ||
plugins: { | ||
autoprefixer: {}, | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the doc: https://symfony.com/doc/4.4/frontend/encore/postcss.html
|
||
{{ encore_entry_link_tags('public', null, app.environment == 'dev' ? 'dev' : 'prod') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now test environment is using prod assets that are generated.
did this change because on CI dev assets are not generated, and it can happen that on dev we don't have them neither, so using prod assets ensure we don't have assets missing errors when running tests
.splitEntryChunks() | ||
.enableSingleRuntimeChunk() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to match the Webpack Encore Bundle recipe, see https://github.com/symfony/recipes/blob/main/symfony/webpack-encore-bundle/1.10/webpack.config.js#L28-L33
.configureImageRule({ | ||
type: 'asset', | ||
maxSize: 500 * 1024, // see https://github.com/symfony/webpack-encore/issues/1132 | ||
}) | ||
.configureFontRule({ | ||
type: 'asset', | ||
maxSize: 500 * 1024, // see https://github.com/symfony/webpack-encore/issues/1132 | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asset/inline
is not working, so here a trick to force inlining images and fonts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are tracking prod asset into Git because we don't want end user to install node, yarn, etc.. to build asset on their side.
If assets are ready from the repo, it's way much easier for us. We do already have a lot of request because of server installation problem and we don't want to add more with the installation of node, etc 😬
|
||
/* Shortcuts */ | ||
|
||
/* Go to */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that coming from a deleted file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't the name change each time the file is built?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but as the goal is to remove prod built assets from the repo the build folder will be ignored :)
@j0k3r I completely understand! but having them in the development repository and having them in the en user release ready to be used it's not the name :) |
You are totaly right, this can be done when we create the archive ready to be installed and attached to each release. |
@j0k3r for reference there are wallabag/docker#362 for Docker and #6982 for ZIP releases that build assets on the fly for those artifacts. |
This PR is doing multiple things that could be extracted in separated PR later if you want.
I'm opening it as draft so that you can have a look at it, and so that we can start taking decisions and drafting solutions to the issues I faced.
What this PR is about more precisely:
edit: found a solution, see #6823 (comment)
It's really almost done and it actually works!
But there is one thing that is a blocker: the fact that production generated assets are tracked in the repository.
Why is that an issue: Webpack Encore relies mainly on 2 files, manifest.json and entrypoints.json
It's possible to have different manifests for prod and dev (what I did already), but for entrypoints.json it's not possible.
And this leads to the fact that the file is changed when running dev build or watch. Not a super DX, see commit
[WIP] issue after dev build
for what happen after to the tracked entrypoints.jsonSo what would be the right direction in your option?
To me, production generated assets shouldn't be tracked in the dev repository.
But I guess the docker image and ZIP packages rely on that so not that simple to manage the production assets building step outside the repository. Am I right here?
Feel free to tell me what you accept that I extract in a separated PR, because the folder structure changes are not impacted by the issue mentionned above, just the use of Webpack Encore