Skip to content

Separate output path for fonts in webpacker v6 #3080

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

Closed
sled opened this issue Jul 6, 2021 · 5 comments
Closed

Separate output path for fonts in webpacker v6 #3080

sled opened this issue Jul 6, 2021 · 5 comments

Comments

@sled
Copy link

sled commented Jul 6, 2021

In v6.0.0-beta.7 the images and fonts are outputted in the same images/ folder, i.e I get this in my manifest.json:

"/packs/media/images/24e1f7f06b6876bf398d.eot",
"/packs/media/images/6cf5f320e27be83645d8.woff",
"/packs/media/images/e8e73160b2e1347f5f75.woff2"

In my opinion it would make sense to change this to:

"/packs/media/fonts/24e1f7f06b6876bf398d.eot",
"/packs/media/fonts/6cf5f320e27be83645d8.woff",
"/packs/media/fonts/e8e73160b2e1347f5f75.woff2"

All that needs to be done is to split the file rules here and add a separate rule for fonts like this:

// rules/images.js
module.exports = {
  test: [
    /\.bmp$/,
    /\.gif$/,
    /\.jpe?g$/,
    /\.png$/,
    /\.tiff$/,
    /\.ico$/,
    /\.avif$/,
    /\.webp$/,
    /\.svg$/
  ],
  exclude: [/\.(js|mjs|jsx|ts|tsx)$/],
  type: 'asset/resource',
  generator: {
    filename: 'media/images/[hash][ext][query]'
  }
}
// rules/fonts.js
module.exports = {
  test: [
    /\.eot$/,
    /\.otf$/,
    /\.ttf$/,
    /\.woff$/,
    /\.woff2$/
  ],
  exclude: [/\.(js|mjs|jsx|ts|tsx)$/],
  type: 'asset/resource',
  generator: {
    filename: 'media/fonts/[hash][ext][query]'
  }
}

What do you think?

@guillaumebriday
Copy link
Member

I opened this PR before seeing this issue: #3082

But what do you think to put everything in the static folder?

I see no need to split images and fonts even for caching 🤔 do I miss something?

@JoeWoodward
Copy link

Also experiencing this

@JoeWoodward

This comment has been minimized.

@sled
Copy link
Author

sled commented Jul 7, 2021

I opened this PR before seeing this issue: #3082

But what do you think to put everything in the static folder?

I see no need to split images and fonts even for caching 🤔 do I miss something?

No need to have explicit paths, it’s a purely cosmetic issue. Putting all assets in the static would be a good solution to keep things consistent.

@guillaumebriday
Copy link
Member

Ok fine, I close the issue then 👌

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants