bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

[Request] Add extract-text-webpack-plugin Support #14

Closed full-of-foo closed 8 years ago

full-of-foo commented 8 years ago

This plugin does not currently respect the Webpack ExtractTextPlugin

module: {
    loaders: [
        { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader!css-loader!resolve-url") },
        { test: /\.(png|jpg)$/, loader: 'url-loader?name=[path][name].[ext]?[hash]'},
        { test: /\.(woff|svg|ttf|eot)([\?]?.*)$/, loader: "file-loader?name=[name].[ext]?[hash]"}
    ]
}
plugins: [
    new ExtractTextPlugin('css/[name].bundle.css', {allChunks: true})
]
~/foo/node_modules/extract-text-webpack-plugin/index.js:118
    Object.keys(b).forEach(function(key) {
           ^
TypeError: Object.keys called on non-object
    at Function.keys (native)
    at mergeOptions (/~/foo/node_modules/extract-text-webpack-plugin/index.js:118:9)
    at Function.ExtractTextPlugin.extract (~/foo/node_modules/extract-text-webpack-plugin/index.js:134:29)
    at Object.<anonymous> (~/foo/webpack.config.js:34:57)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
bholloway commented 8 years ago

I can show an example of extract-text-webpack-plugin working. But that said I am definitely interested in how your use case is not working.

I can immediately see that you have only one loader specified in extract().

ExtractTextPlugin.extract([notExtractLoader], loader, [options])

Has this first option (notExtractLoader) always been optional? Anyhow just now I omitted it in my example and everything still worked.

Do you have any other warnings in your failing build? It may be that resolve-url-loader is warning that it cannot operate.

bholloway commented 8 years ago

On second look I think that you should be using the style-loader as your nonExtractLoader only. If you never intend to disable the plugin then just remove it completely.

Event if this does not solve the error at hand I think it will be a problem for you following.

bholloway commented 8 years ago

Hey @full-of-foo. How did you go with this?

full-of-foo commented 8 years ago

@bholloway I opted to use npm packages over bower packages for my frontend deps which ultimately fixed my URL loading issues, so in the end I did not need resolve-url-loader. Sorry this isn't much help

bholloway commented 8 years ago

Ok @full-of-foo I'm going to close this for now. If anyone else encounters this I can reopen.

In some of my applications I am also using Bower and experience a lot of issues as a result. Definitely npm is the happy path so go with that where you can.