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

docs(configuration): Change chunkhash to hash #1445

Closed

Conversation

ematipico
Copy link
Contributor

The filename options supports hash and not chunkhash.
chunkhash is only for chunkFilename option.

@ematipico ematipico changed the title Change chunkhash to hash docs(configuration): Change chunkhash to hash Jul 18, 2017
@skipjack
Copy link
Collaborator

Thanks for your contribution but chunkhash is available for filename (see the table) and should be the default based on the practices recommended in the caching guide. Could you document why this change is necessary or provide an example using the latest version of webpack where this doesn't work?

@skipjack skipjack closed this Jul 20, 2017
@skipjack
Copy link
Collaborator

Related: #1436

@ematipico
Copy link
Contributor Author

ematipico commented Jul 20, 2017

That's weird. Webpack 3.3.0 was complaining about that, saying that I needed to use hash instead of chunkhash for filename

@skipjack
Copy link
Collaborator

skipjack commented Jul 20, 2017

Hmmm I just used chunkhash in TheDutchCoder/webpack-guides-code-examples#17 with webpack 3.3.0 and didn't get any errors. Can you maybe pull that example and see if you are able to reproduce the issue? It may be a bug with webpack 3 but as far as I know chunkhash should be available.

@skipjack
Copy link
Collaborator

Maybe it's some combination of things in your config that's causing that error to be thrown, even if that's the case though it may be a bug or maybe the error isn't detailed enough. Or, maybe a breaking change was introduced that I'm not aware of but this wasn't mentioned in either of the release docs issues ( #1318 or #1388 ) or in the main repo's changelog as far as I know.

cc @webpack/documentation-team

@ematipico
Copy link
Contributor Author

ematipico commented Jul 20, 2017

OK probably I narrowed down the issue.

My output config

    output: {
        path: path.resolve(path.join(__dirname, '/')),
        filename: '[name].[chunkhash].js',
        chunkFilename: '[name].[chunkhash].js',
        publicPath: '/'
    }
[name].[chunkhash].js
Cannot use [chunkhash] for chunk in '[name].[chunkhash].js' (use [hash] instead)

Probably it's not possible to use [chunkhash] inside filename when you have chunkFilename defined. I didn't find anything inside the documentation though

@skipjack
Copy link
Collaborator

I think the maybe that error is actually flagging the use of [chunkhash] within chunkFilename. Maybe for chunkFilename only [hash] is supported. I agree that this error is a bit confusing. I'll re-open so we can get some clarification.

cc @bebraw @sokra @TheLarkInn

@sokra
Copy link
Member

sokra commented Jul 20, 2017

With HMR enabled you can't use [chunkhash] for technical reasons.

For dev builds with HMR -> use [hash].

@ematipico
Copy link
Contributor Author

The configuration that I am using doesn't use the HMR. The local web server is launched using another technology. Is it because there's the --watch flag?

@skipjack
Copy link
Collaborator

Is it because there's the --watch flag?

It seems that's likely the case, e.g. if webpack is in "Watch Mode" -- [chunkhash] is forbidden. I'll let @sokra clarify but if this is the case maybe we should just add a warning under the substitutions table like so:

W> Note that `[chunkhash]` cannot be used in conjunction with "Watch Mode". For example, if you're using `webpack-dev-server` or `webpack-dev-middleware` during development, you will get an error using `[chunkhash]` within your development configuration.

@ematipico
Copy link
Contributor Author

ematipico commented Jul 21, 2017

I get this error even on production build. I don't run any watcher or HMR thing.
I run the command

 webpack --config webpack.config.prod.js --optimize-minimize --colors --profile --progress

The output statement is the same of the one that I pasted before. I tried to reproduce it on another smaller repo but no joy. I guess there's a combination of settings that fires that error...

@ematipico
Copy link
Contributor Author

Found the cause of that error, which is now filed here webpack/webpack#5337

I close the PR

@ematipico ematipico closed this Jul 21, 2017
@skipjack
Copy link
Collaborator

Awesome -- thanks @ematipico for following up on this!

@ematipico ematipico deleted the bugfix/ematipico-patch-hash branch July 21, 2017 15:11
@ICELI ICELI mentioned this pull request Sep 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants