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 trialBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsWhy 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?
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsSo I could use them interchangeably?
1 Answer
Jared Schaab
Treehouse Guest TeacherThat is correct. Here is a link to the loaders documentation.
Jared Schaab
Treehouse Guest TeacherJared Schaab
Treehouse Guest TeacherBrandon, the two usages actually accomplish the same thing. I personally prefer:
loaders: ['loader1', 'loader2', 'loadern']
Hope that helps.