webpack-contrib / imports-loader

Imports Loader
MIT License
520 stars 63 forks source link

Example config is incorrect #10

Closed Nevon closed 8 years ago

Nevon commented 9 years ago

The example configuration file for using the imports loader is wrong:

// ./webpack.config.js

module.exports = {
    ...
    module: {
        loaders: [
            {
                test: require.resolve("some-module")
                loader: "imports?this=>window"
            }
        ]
};

The test property is according to the webpack documentation a condition that "may be a RegExp, a string containing the absolute path, a function(absPath): bool, or an array of one of these combined with 'and'.". require.resolve, on the other hand, returns a module id that is either a number or a string, depending on the environment.

sokra commented 9 years ago

require.resolve returns an absolute path to the file in node.js.