Created
June 20, 2018 16:11
-
-
Save coreysnyder/f0170f9b7c19620716f9d3049c27207e to your computer and use it in GitHub Desktop.
What's the difference?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've seen 3 different ways loaders are used, and I'm not sure what the the heck the difference is, | |
or which ones are even necessary. | |
//####### In .babelrc file | |
{ | |
"presets": ["@babel/preset-env", "@babel/preset-react"] | |
} | |
//####### In package.json file | |
"babel": { | |
"presets": [ | |
"@babel/preset-env", | |
"@babel/preset-react", | |
] | |
} | |
//####### In Webpack config loaders | |
.... | |
module: { | |
rules: [ | |
{ | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules\/(?!(@myfiles)\/).*|bower_components)/, | |
use: [ | |
{ | |
loader: 'babel-loader', | |
options: { | |
presets: ['@babel/preset-env', '@babel/preset-react'], | |
retainLines: true | |
} | |
} | |
] | |
}, | |
} | |
] | |
} | |
.... | |
/########################## | |
One thing I found is that if I omit the the preset definitions in my webpack config then I | |
get errors with uglifyjs and other random things. When do you need each? Which are redundant? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I dont know the @babel tag does at the front, but this is how we with out @babel tag.
Also never use any configuration in package.json file.
here is the version of babel in use at the moment for me