Answer the question
In order to leave comments, you need to log in
Why does babel compile React in 25k+ lines of code?
If I compile regular js, then everything is ok, a few lines of code and everything compiles as it should, but when I start compiling react - in general, the simplest component with a hello word line, the output is 30k lines of code. My question is, is this how it should be? Or what to do about it?
// webpack.config.js
const path = require('path');
const miniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: 'development',// production / development
entry: {
index: "./src/index.js"
},
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, 'public'),
clean: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.s?css$/i,
use: [miniCssExtractPlugin.loader, "css-loader", "sass-loader", "postcss-loader"]
}
]
},
resolve: {
extensions: ['.js', '.jsx'],
},
plugins: [new miniCssExtractPlugin()],
devtool: 'source-map',
}
module.exports = {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question