Skip to content

How to change output filename for the extracted CSS? #325

Closed
@mydnicq

Description

@mydnicq

I found that current vue-build in production mode offers fixed filename for the extracted CSS which is taken from the entry path:

In https://github.com/vuejs/vue-cli/blob/master/bin/vue-build

new ExtractTextPlugin(options.lib ? `${replaceExtension(options.entry, '.css')}` : '[name].[contenthash:8].css')

I have a different project folder structure and I need to define a custom filename for the extracted CSS. How this can be achieved?

My temporary solution is presented below, but I think there must be a better way.

module.exports = {

  webpack(defaults, options) {
    defaults.output.filename = './index.js'
    defaults.plugins.find(el => {
      if (el.constructor.name === 'ExtractTextPlugin') {
        el.filename = './style.css'
      }
    })
    return defaults;
  }

};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions