Skip to content

Conversation

fabianonunes
Copy link
Contributor

@fabianonunes fabianonunes commented Dec 7, 2016

Consider that the following two modules pass through file!extract!css:

font.css:

@font-face {
  font-family: 'FancyFont';
  src: url('webfont.woff2?v=1.0.0') format('woff2');
  /*                     ^^^^^^^^                 */
}

main.css

.fancy {
  font-family: 'FancyFont';
}

I can't explain the why, but the module font.css is never cached by webpack if the querystring ?v=1.0.0 is appended to the path. So, when a change is made in main.css, both chunks (main.css and font.css) is compiled and emitted (slowing the rebuild).

If we remove the querystring part from font path, a change in main.css will emit only the second chunk (as expected).

Trying to find a solution, I removed the querystring from dependency's absolute path:

const absPath = path.resolve(path.dirname(this.resourcePath), resourcePath).split('?')[0]

It seems it's working, but I'm very newbie with webpack internals and don't know if this is an acceptable solution.

@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Coverage remained the same at 98.039% when pulling 509fe0e on fabianonunes:master into e8a6103 on peerigon:master.

@jhnns jhnns merged commit d70a987 into peerigon:master May 22, 2017
@jhnns
Copy link
Member

jhnns commented May 22, 2017

Thx for that fix. I probably need to refactor it a little bit, but the gist is correct. require() actually receives a request which might not be an absolute path (like in your case). That's why the fs watcher triggered by addDependency() does not work correctly.

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

Successfully merging this pull request may close these issues.

3 participants