Vue-cli: Can't disable hashing from build

Created on 21 Jun 2018  路  8Comments  路  Source: vuejs/vue-cli

Version

3.0.0-rc.3

Steps to reproduce

Have tried below two options as suggested in docs... but doesn't seem to work

//vue.config.js

module.exports = {
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        args[0].hash = false;
        return args
      })
  }
}

module.exports = {
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => [{
        hash: false
      }])
  }
}

What is expected?

Was expecting output file name to be just app.css instead of app.########.css

What is actually happening?

I am getting app.########.css

Most helpful comment

Try:

// vue.config.js
module.exports = {
  chainWebpack: config => {
    if(config.plugins.has('extract-css')) {
      const extractCSSPlugin = config.plugin('extract-css')
      extractCSSPlugin && extractCSSPlugin.tap(() => [{
        filename: '[name].css',
        chunkFilename: '[name].css'
      }])
    }
  },
  configureWebpack: {
    output: {
      filename: '[name].js',
      chunkFilename: '[name].js'
    }
  }
}

All 8 comments

Use

  • '[name].js' for output.filename and output.chunkFilename in chainWebpack
  • { filename: '[name].css' } for css.extract option in vue.config.js.

Try:

// vue.config.js
module.exports = {
  chainWebpack: config => {
    if(config.plugins.has('extract-css')) {
      const extractCSSPlugin = config.plugin('extract-css')
      extractCSSPlugin && extractCSSPlugin.tap(() => [{
        filename: '[name].css',
        chunkFilename: '[name].css'
      }])
    }
  },
  configureWebpack: {
    output: {
      filename: '[name].js',
      chunkFilename: '[name].js'
    }
  }
}

@yyx990803 @Akryum That worked... Thank you.

@Akryum This should really go into documentation, it would help a lot of people.

@yyx990803 Maybe we can add a "Common recipes" page in the docs?

How to disable filenameHashing on a specific file/chunk?
I have a case to disable the hashing for only each of theme.scss

Evan's solution looks like this in vue.config.js:

module.exports = {
  configureWebpack: config => {
    config.output.filename = '[name].js'
    config.output.chunkFilename = '[name].js'
  },
  css: {
    extract: {
      filename: '[name].css',
    },
  },
}

Just adding this here, to keep people up to date. This is now an option in vue.config.js:

https://cli.vuejs.org/config/#filenamehashing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chasegiunta picture chasegiunta  路  3Comments

BusyHe picture BusyHe  路  3Comments

NathanKleekamp picture NathanKleekamp  路  3Comments

Gonzalo2683 picture Gonzalo2683  路  3Comments

CodeApePro picture CodeApePro  路  3Comments