Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Hot Reloading your React App

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

Why do we use β€˜loaders’ differently here?

From video at 1:15, in webpack.config.js we have this file:

module.exports = {
    entry: './app.js',

    output: {
        // path: 'build',
        filename: 'bundle.js'
    },

    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loaders: ['react-hot', 'babel-loader'] 
            },
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader'
            }

        ]
    },
};

On line 14 we put in multiple loaders with an array:

loaders: ['react-hot', 'babel-loader'].

On line 18 we put in multiple loaders with a string and values separated by an exclamation point:

loader: 'style-loader!css-loader'

Why do we do it differently?

Jared Schaab
Jared Schaab
Treehouse Guest Teacher

Brandon, the two usages actually accomplish the same thing. I personally prefer:

loaders: ['loader1', 'loader2', 'loadern']

Hope that helps.

1 Answer

Jared Schaab
STAFF
Jared Schaab
Treehouse Guest Teacher

That is correct. Here is a link to the loaders documentation.