joeeames / WebpackFundamentalsCourse

272 stars 122 forks source link

preLoader property no longer exists #12

Closed JamesDaniel closed 7 years ago

JamesDaniel commented 7 years ago

The property preLoader no longer exists for the webpack configuration file. I was getting this error:

configuration.module has an unknown property 'preLoaders'.

I found a solution to this problem here: http://stackoverflow.com/questions/39668579/webpack-2-1-0-beta-25-error-unknown-property-postloaders

So the code:

module.exports = {
    entry: ["./utils", "./app.js"],
    output: {
        filename: "bundle.js"
    },
    watch: true,

    module: {
        preLoaders: [
            {
                test: /\.js$/, // include .js files
                exclude: /node_modules/, // exclude any and all files in the node_modules folder
                loader: "jshint-loader"
            }
        ],
        loaders: [
            {
                test: /\.es6$/,
                exclude: /node_modules/,
                loader: "babel-loader"
            }
        ]
    },
    resolve: {
        extensions: ['.js','.es6']
    }
}

Should now look like this:

module.exports = {
    entry: ["./utils", "./app.js"],
    output: {
        filename: "bundle.js"
    },
    watch: true,

    module: {
        loaders: [
            {
                test: /\.es6$/,
                exclude: /node_modules/,
                loader: "babel-loader"
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "jshint-loader",
                enforce: 'pre'
            }
        ]
    },
    resolve: {
        extensions: ['.js','.es6']
    }
}

This is from the pluralsight tutorials: https://app.pluralsight.com/player?course=webpack-fundamentals&author=joe-eames&name=webpack-fundamentals-m2&clip=6&mode=live

Basic Building with Webpack

Using Preloaders

Because of this the tutorials are no longer up to date with the latest version of webpack.

joeeames commented 7 years ago

ok, I'll update the readme to include this note.

joeeames commented 7 years ago

I've incorporated this into the course readme and marked the course as out of date. I'm going to close this issue.

hanguyenk commented 7 years ago

The module.loaders is now module.rules. Although the old naming convention is still valid, I think we should have some notes about that. FYI: https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules