For those who are facing problems in 2021, May can follow these lines below: npm install babel-loader @babel/core @babel/preset-env --save and then webpack.config.js file should be like this: module.exports = { entry: "./src/script1.js", output: { path: __dirname + "/dist", filename: "bundle.js", }, module: { rules: [ { test: /\.js$/, exclude: /(node_modules)/, use: { loader: "babel-loader", options: { presets: ["@babel/preset-env"], }, }, }, ], }, mode: "none", } And so you will get bundle.js file in /dist folder.
Hi, great video! I wanted to ask why do you need the exclude option when you already have the entry option to the js-1 script? If the js-1 script isn't requiring anything from the node_modules folder, doesn't webpack then know to just completely ignore them?
For those who are facing problems in 2020,May, follow these, npm install @babel-core -save npm install @babel/preset-env -save and webpack.config.js file should be like this, module.exports = { entry: './src/script1.js', output:{ path: __dirname + "/dist", filename:'bundle.js' }, module:{ rules:[ { test:/\.js$/, exclude:/(node_modules)/, loader:'babel-loader', query:{ presets:['@babel/preset-env'] }, } ] }, mode: 'none' } this will create a 'bundle.js' file in /dist folder, If you install @babel-core and @babel/preset-env, you will get a nice line by line, bundle.js file, otherwise not. Thanks.
Hi, thanks for your videos. I've got an question. I wanna use a html theme that contains lots of css and js libararies how should i organize this file from just one places when i added to thhse referance in index.html file, that doesen't work correctly can you help me go solve this problem. If you've got any referance can you provide? Thanks.
I tried the examples in this video without babel and bundle contains ES2015 code that is successfully executed by Chrome. Is that mean the browser is update to recognize es2015 and we don't have to use this loader for es2015 code?
For those who are facing problems in 2021, May can follow these lines below:
npm install babel-loader @babel/core @babel/preset-env --save
and then webpack.config.js file should be like this:
module.exports = {
entry: "./src/script1.js",
output: {
path: __dirname + "/dist",
filename: "bundle.js",
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
},
],
},
mode: "none",
}
And so you will get bundle.js file in /dist folder.
Thank you very much . I can add to this. Watch out file name script-1.js instead of script1.js and remember you run webpack with command: npx webpack.
For the latest version of webpack change 'loaders:' to 'rules:'
and 'babel-core' to 'babel-loader'
Yeah ninja, the babe loader is fine as well!
I came here for Babe Loader, I got duped and got Babel Loader instead.
Give me back my Babe Loader!!!
Honestly was searching for you xD...
I will prefer "babe-loader" xD.
2018:
"From v2.1-beta.23 the loaders section is renamed to rules"
Where is your "Ninja" sound?!? "WHHHHhaaaaa!!!!!!!!". Man, I love watching your videos just because of that sound. Made me laugh every time :-)
Unfortunately it gave too many people a scare :(. But maybe I'll sneak it back in to some of my new video's!
Hi, great video! I wanted to ask why do you need the exclude option when you already have the entry option to the js-1 script? If the js-1 script isn't requiring anything from the node_modules folder, doesn't webpack then know to just completely ignore them?
Love your easy explanations!
Hey great tutorials I really like them.
Hey, ShaunJP what does the babel-core actually do?
For those who are facing problems in 2020,May, follow these,
npm install @babel-core -save
npm install @babel/preset-env -save
and webpack.config.js file should be like this,
module.exports = {
entry: './src/script1.js',
output:{
path: __dirname + "/dist",
filename:'bundle.js'
},
module:{
rules:[
{
test:/\.js$/,
exclude:/(node_modules)/,
loader:'babel-loader',
query:{
presets:['@babel/preset-env']
},
}
]
},
mode: 'none'
}
this will create a 'bundle.js' file in /dist folder,
If you install @babel-core and @babel/preset-env, you will get a nice line by line, bundle.js file, otherwise not.
Thanks.
inorder to avoid following error,
ERROR in ./index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '@babel/core'
instead of
npm install babel-core babel-loader babel-preset-es2015 --save-dev
use
npm install @babel/core --save-dev
npm install @babel/preset-env --save-dev
webpack.config.js shhould be like this
module.exports={
//define entry point
entry:'./index.js',
//define output
output:{
path:'F:\\webpack-playlist\\dist',
filename:'bundel.js'
},
module:{
rules:
[
{
test:/\.js$/,
exclude:/(node_modules)/,
loader:'babel-loader',
query:
{
presets:['@babel/preset-env']
}
}
]
}
};
thanks. All worked fine in 2020 except that we have to add an additional property "mode:'none' "
Wait, what's the point of putting const type if its just going to translate it to a var type?
Hi, thanks for your videos. I've got an question. I wanna use a html theme that contains lots of css and js libararies how should i organize this file from just one places when i added to thhse referance in index.html file, that doesen't work correctly can you help me go solve this problem. If you've got any referance can you provide? Thanks.
Thats what this is all about..isnt it?What do you think webpack does...if not organize all the js files into one "bundle" file
ES2015, ES2016, ES2017 and ESNext are all vanilla JS. They're all plain JS, but different versions.
I tried the examples in this video without babel and bundle contains ES2015 code that is successfully executed by Chrome. Is that mean the browser is update to recognize es2015 and we don't have to use this loader for es2015 code?
chrome is up to date with ES6 (except modules), while other browsers may not, e.g. IE 11
Who knows why in my bundle.js file variables names have only one letter e.g var r, t, n?
nothing is work, you need to update this course shaun
Nowadays you call it rules instead of loaders