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

Webpack dev server and [hash] file names #438

Closed
kamarouski opened this issue Mar 26, 2016 · 2 comments
Closed

Webpack dev server and [hash] file names #438

kamarouski opened this issue Mar 26, 2016 · 2 comments
Labels

Comments

@kamarouski
Copy link

Does webpack-dev-server supports bundle names with [hash] in file name?

I have the following setup:

module.exports = {
  context: __dirname,
  entry: './app/test.js',
  output: {
    filename: '[name].[hash].js',
    path: path.join(__dirname, "dist"),
  },
  module: {
    loaders: [{ test: /\.js$/, loader: 'babel', exclude: /node_modules/, query: { presets: ['es2015']}} ]
  },
  plugins: [new ExtractTextPlugin("[hash].css"), new AssetsWebpackPlugin()]
}

All assets generated correctly, but how can I reference it in my index.html? Js or css file name depends on [hash] value and changes with every build.

@manuelmazzuola
Copy link

manuelmazzuola commented Jul 7, 2016

There is no need to use hash in webpack dev server, there is no cache problems.

@SpaceK33z
Copy link
Member

It does work in webpack-dev-server, but it is not recommended. If you do this, on every incremental build the server will generate a new JS file with the hash in it. The old files will not be removed, so the process will slowly run out of memory.

I'm using this hack in my config:

const IS_DEV_SERVER = process.argv[1].indexOf('webpack-dev-server') >= 0;

module.exports = {
    output: {
        filename: `[name]-${IS_DEV_SERVER ? 'dev' : '[hash:7]'}.js`,
    },
};

khalwat added a commit to nystudio107/annotated-webpack-config that referenced this issue Aug 13, 2020
Bcdo added a commit to Bcdo/project that referenced this issue Aug 14, 2020
- Added `--no-tablespaces` to the mysqldump command options to work around changes in MySQL

 Fixed
- Modern config only for local dev, [fixing multi-compiler issues](webpack/webpack-dev-server#2355) with HRM
- Fix redis session config to use `App::sessionConfig()`

Changed
- Remove `[hash]` from dev config to eliminate potential [memory errors](webpack/webpack-dev-server#438)
- Use `[contenthash]` in production instead of [hash or chunkhash](webpack/webpack.js.org#2096)

- Readme file to give proper credit

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

No branches or pull requests

4 participants