I’m using the ExtractTextPlugin to build a separate CSS file. It works great but I’d really like to output the CSS into a different directory than the JS:
module.exports = {
entry: {
module: "./source/javascripts/app.js",
},
output: {
path: './source/built/',
filename: 'app.js'
},
module: {
loaders:[
{
test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
}
]
},
plugins: [
new ExtractTextPlugin('app.css')
]
};
Currently both files go into ./source/built
, is there a way to change this?
Did you try:
Not sure if it works, just a guess.
Also, issue probably belongs to extract-text-webpack-plugin repo than here.
This actually was a similar problem I was facing and andreypopp’s answer solved it for me. Specifically, what worked for me was:
Ah nice, in my example I was able to use
new ExtractTextPlugin("../css/[name].css")
to solve moving it to a different dir.Thanks
This worked for me..
@iDVB maybe cause you’re using
url loader
to extract images and as they are ‘small’ they are embedded in base64.If I use
file-loader
or if I have big images the css’url(...)
are pointing to the wrong directory (I’ve got everything underassets/
and the css is rewritten withurl(assets/example.png)
instead ofurl(example.png)
@ulfryk I don’t know how @iDVB‘s solution solves this and also don’t know how late it is for you but I was able to get this working by doing the following.
If the above is not as clear then basically you’d need to add
publicPath
in yourfile-loader
query to overridepublicPath
that’s at the parent level while still putting the public path, or in my caseassets
, in thename
query offile-loader
so that it extracts to the right public directory while keeping the right url in the css.Hope that clarifies a little and helps others as well cause it took me almost a day to figure this out.
Randomly stumbled here. This plugin will make your life much easier.
https://github.com/webpack-contrib/copy-webpack-plugin