You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I'd like to give you a big 👏 for this work.
We just finished to port our manual webpack wiring in our Symfony app to webpack encore, and it works well !
However, I had to use configureLoaderRule in order to load images and fonts from a relative path:
We deploy our assets on a CDN, in a subfolder. When we're building assets, we dont know yet what will be the subfolder.
So we want that images and fonts are loaded relatively to the css file instead of an absolute path:
Encore
// directory where compiled assets will be stored
.setOutputPath('../public/build')
// public path used by the web server to access the output path
.setPublicPath('/build')
// only needed for CDN's or sub-directory deploy
.setManifestKeyPrefix('build/')
// Needed because webpack encore use absolute path, and we release in a CDN folder
.configureLoaderRule('fonts', (rules) => {
rules.options.publicPath = function (url) {
return `./${url}`;
};
})
// Needed because webpack encore use absolute path, and we release in a CDN folder
.configureLoaderRule('images', (rules) => {
rules.options.publicPath = function (url) {
return `./${url}`;
};
})
module.exports = Encore.getWebpackConfig();
When using configureLoaderRule a WARNING is displayed when building, and I was wondering if there were a better way to achieve this.
I've seen that there were some works years ago at #179, but maybe there is a more recent and proper way of doing this that I've missed.
Thanks!
The text was updated successfully, but these errors were encountered:
Hello,
First, I'd like to give you a big 👏 for this work.
We just finished to port our manual webpack wiring in our Symfony app to webpack encore, and it works well !
However, I had to use
configureLoaderRule
in order to load images and fonts from a relative path:We deploy our assets on a CDN, in a subfolder. When we're building assets, we dont know yet what will be the subfolder.
So we want that images and fonts are loaded relatively to the css file instead of an absolute path:
When using
configureLoaderRule
a WARNING is displayed when building, and I was wondering if there were a better way to achieve this.I've seen that there were some works years ago at #179, but maybe there is a more recent and proper way of doing this that I've missed.
Thanks!
The text was updated successfully, but these errors were encountered: