Use Babel & Webpack To Compile ES2015 - ES2017

Use Babel & Webpack To Compile ES2015 - ES2017

Traversy Media

6 лет назад

113,627 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

jojo johnson
jojo johnson - 10.02.2023 12:48

The github links are not accessible

Ответить
Elkhan Hamet
Elkhan Hamet - 27.11.2022 03:28

Thanks Brad😊😊😊👍👍👍

Ответить
Aman Khanna
Aman Khanna - 17.12.2021 13:20

Thanks for this brother 🔥

Ответить
Shalini Wadhera
Shalini Wadhera - 11.09.2021 03:50

Thanks for the video, always webpack and babel was a black box to me, not anymore

Ответить
王甯
王甯 - 15.08.2021 09:09

You didn't explain why you put a `?` in the `/\.js?$/`?

Ответить
lambsack111
lambsack111 - 10.07.2021 19:19

2021 Possible Fix that worked for me:

>> npm uninstall webpack --save-dev
>> npm install [email protected] --save-dev //this is the current version at this time//

Then go into webpack.config.js and add in a mode option to the module.exports object:

module.exports = {
entry: {
app: './src/app.js'
},
output: {
path: path.resolve(__dirname, 'build'),
filename: 'app.bundle.js'
},
module: {
rules: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
}
}]
},
//THIS PART IS NEW//

mode: 'none',
}

Ответить
Rajesh Jha
Rajesh Jha - 12.06.2021 07:25

If you're having issues :-

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[0] has an unknown property 'query'. These properties are valid:
object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
-> A rule description with conditions and effects for modules.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Try the below steps:

npm uninstall webpack --save-dev
&
npm install [email protected] --save-dev

Ответить
Nicholas Orth
Nicholas Orth - 29.05.2021 16:03

In our webpack.config.js module, "query" no longer exists. It should be:

options: {
presets: ['@babel/preset-env']
}

Ответить
d三n Nis
d三n Nis - 05.04.2021 09:30

this is might be out of the topic but please allow me to ask you, what apps you used on your desktop clock. or how did you do that. i really love your desk top clock. please share it to me.....

Ответить
Jashan Preet
Jashan Preet - 14.03.2021 07:31

Good

Ответить
Tarun Nagpal
Tarun Nagpal - 27.02.2021 10:34

Thank you so much

Ответить
Cyrus Manatad
Cyrus Manatad - 20.02.2021 13:08

I wish I know this a long time ago, this really helps to web performance.
Thank you, sir!

Ответить
Abanoub Ashraf
Abanoub Ashraf - 11.02.2021 11:16

hey is there's any chance you can update this video?

Ответить
Uchiha Babble
Uchiha Babble - 01.02.2021 16:26

Some changes in 2021:
1) in webpack.config.js, inside rules instead of query give options
2) in package.json, in "start", give webpack serve instead of webpack-dev-server
OTHER CHANGES ARE MENTIONED IN THE COMMENTS BELOW

Ответить
Marin
Marin - 01.02.2021 15:08

this is great, thx a lot man!

Ответить
Melody Yi
Melody Yi - 08.01.2021 02:19

fdsfddf

Ответить
surrocclusion
surrocclusion - 21.12.2020 20:42

Thanx for the nice video. So u are saying that if I build a simple website using ES6 but no node.js then I can still use babel and webpack? Is that right? But I would still need to install node, right? is there an option to use these things without node?

Ответить
Alexe Alexandru Daniel
Alexe Alexandru Daniel - 18.11.2020 12:04

The year now is 2020 and modules->rules no longer has query. It can be changed to options.
module: {
rules: [{
// loader will parse and compile all files with .js extension
test: /\.js?$/,
// we exclude entire node_module from compiling
exclude: /node_module/,
// set compiler
loader: 'babel-loader',
options: {
presets: [ '@babel/preset-env' ] }
}]
}

Ответить