newish to Webpack and brand new to Babel. I'm trying to set Babel up for my company's JS files to support older browsers, and am having an issue setting it up. Running the npm run start
script does nothing. However, if I comment out the Babel module under my webpack.config.json
, npm run start
returns the normal functionality. Can someone tell me where I'm going wrong?
I installed Babel using the following command:
npm install -D babel-loader @babel/core @babel/preset-env webpack
package.json
{
// Name, etc here.
"scripts": {
"start": "webpack"
},
"devDependencies": {
"@babel/core": "^7.18.13",
"@babel/preset-env": "^7.18.10",
"babel-loader": "^8.2.5",
"browserslist": "^4.21.3",
"webpack": "^5.74.0",
"webpack-cli": "^4.9.2"
},
"browserslist": [
" > .5%, last 2 versions, iOS 12.1, Safari 13"
]
}
Webpack.json
const path = require("path");
module.exports = {
entry: {
theme: __dirname "/assets/js/modules-theme/index.js",
product: __dirname "/assets/js/modules-product/index.js",
},
output: {
filename: "[name].bundled.js",
path: path.resolve(__dirname, "assets/js/"),
},
//mode: "development",
mode: "production",
watch: true,
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
},
],
},
};
Thanks to all for any help.
CodePudding user response:
After a system restart, I was able to fix this issue. All is working now. I will delete this question after.