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

Fonts are not being included in second and consecutive builds #517

Open
kerkocee opened this issue Nov 20, 2019 · 6 comments
Open

Fonts are not being included in second and consecutive builds #517

kerkocee opened this issue Nov 20, 2019 · 6 comments

Comments

@kerkocee
Copy link

kerkocee commented Nov 20, 2019

Expected Behavior

Fonts are included in second and consecutive builds, just like the first run.

Actual Behavior

Fonts are not being included in second and consecutive builds.

Is an error being thrown?

No.

Steps to Reproduce

  1. Run the app for the first time, it builds fine and fonts are included as expected.
  2. Stop the app and run it second time, no errors with build but fonts are not included and broken on UI.

Using file-loader for ttf and woff fonts.
Using postcss-loader, css-loader and extract-css-chunks-webpack-plugin/loader for scss files.

Using hard-source-webpack-plugin as following:

new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ExcludeModulePlugin([
  {
    test: /extract-css-chunks-webpack-plugin[\\/]dist[\\/]loader/,
  },
]),

Operating System, Node, and NPM dependency versions

Mac OS 10.13.6
Node 8.10.0

"devDependencies": {
  "@babel/cli": "^7.4.3",
  "@babel/core": "^7.4.3",
  "@babel/node": "^7.2.2",
  "@babel/polyfill": "^7.4.3",
  "@babel/preset-env": "^7.4.3",
  "@babel/preset-react": "^7.0.0",
  "@babel/preset-typescript": "^7.7.2",
  "@babel/runtime": "^7.4.3",
  "babel-loader": "^8.0.0",
  "css-loader": "^1.0.1",
  "extract-css-chunks-webpack-plugin": "^4.3.0",
  "file-loader": "^3.0.1",
  "hard-source-webpack-plugin": "^0.13.1",
  "html-webpack-plugin": "^3.2.0",
  "postcss-loader": "^2.1.6",
  "style-loader": "^0.19.0",
  "typescript": "^3.6.4",
  "webpack": "^4.27.1", 
  "webpack-cli": "^3.1.2",
  "webpack-dev-middleware": "^2.0.6",
  "webpack-hot-middleware": "^2.24.2",
  "webpack-hot-server-middleware": "^0.3.2",
}

Similar Issues

#357
#378

@runfaj
Copy link

runfaj commented Nov 22, 2019

Also an issue here - using

{
  test: /\.(svg|png|woff2?|otf|eot|ttf)$/i,
  use: {
    loader: 'file-loader'
  },
},

And all woff/otf files and some svgs don't show up on the page.

@sydney-d
Copy link

Hello,

I'm also having this issue, did you find a workaround ?

Thanks

@attikos
Copy link

attikos commented Apr 30, 2020

I solved the problem like this:

new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ExcludeModulePlugin([
    {
        test: /file-loader/,
    },
    {
        test: /webfonts-loader/,
    },
]),

No caching fonts, no problem )

@ChildishGiant
Copy link

@attikos's workaround works well but surely this decreases the speed of the build (and certainly increases developer time since I had to come look for this bug)

@PLQin
Copy link

PLQin commented Jul 22, 2020

I have a question, new HardSourceWebpackPlugin.ExcludeModulePlugin can only be used for loader?

can i use :

new HardSourceWebpackPlugin.ExcludeModulePlugin([
  {
    test: /js-cookie/
  }
]),

@Sociosarbis
Copy link

I have a question, new HardSourceWebpackPlugin.ExcludeModulePlugin can only be used for loader?

can i use :

new HardSourceWebpackPlugin.ExcludeModulePlugin([
  {
    test: /js-cookie/
  }
]),

As the RegExp is applied to the whole request path of the module and module name is also a component of request path, I think the config you suggested above is available.

For details, debug here on yourself. ExcludeModulePlugin.js

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

7 participants