Skip to content

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

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

Closed
mydnicq opened this issue Feb 2, 2017 · 4 comments
Closed

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

mydnicq opened this issue Feb 2, 2017 · 4 comments

Comments

@mydnicq
Copy link

mydnicq commented Feb 2, 2017

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;
  }

};
@egoist
Copy link
Collaborator

egoist commented Feb 2, 2017

You can also use .map to replace that plugin.

maybe add option for this:

module.exports = {
  filename: {
    js: 'index.js',
    css: 'style.css',
    assets: 'static/[name].[ext]'
  }
}

@mydnicq
Copy link
Author

mydnicq commented Feb 2, 2017

Ok great!

@mydnicq mydnicq closed this as completed Feb 2, 2017
@casio
Copy link

casio commented Mar 24, 2017

hey there

hm, I'm using v.2.8.1 and for me filename in the (non-webpack) config seems to be just ignored.

filename: {
    js: 'index.js',
    css: 'style.css',
    assets: 'static/[name].[ext]'
}

..will still output eg client.35a7fe68.js when built with prod

@stevensanborn
Copy link

yeah 3.0 you can map filename , it expects a string no?

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

No branches or pull requests

4 participants