在我的 React 应用中,我正在使用 Webpack。这是我的 webpack.config 配置文件:
我正在尝试从捆绑包中排除
"use strict";
var path = require("path");
var WebpackNotifierPlugin = require("webpack-notifier");
var BrowserSyncPlugin = require("browser-sync-webpack-plugin");
module.exports = {
entry: "./Scripts/reactApp/index.jsx",
output: {
path: path.resolve(__dirname, "./Scripts/reactApp/build"),
filename: "react_bundle.js"
},
module: {
rules: [
{
test: /\.jsx$/,
exclude: [/node_modules/, path.resolve(__dirname, "./Scripts/reactApp/translations/he.translations.json")],
use: {
loader: "babel-loader"
}
},
{
test: /\.js$/,
exclude: [/node_modules/, path.resolve(__dirname, "./Scripts/reactApp/translations/he.translations.json")],
use: {
loader: "babel-loader"
}
}
]
},
devtool: "inline-source-map",
plugins: [new WebpackNotifierPlugin(), new BrowserSyncPlugin()]
};
我正在尝试从捆绑包中排除
he.translations.json
,但无论如何 webpack 都会将它包含进去。
你能解释一下我做错了什么吗?提前道歉,我对webpack还很新。
{ test: /\.(js|jsx)$/, exclude: [/node_modules/, path.resolve(__dirname, 'src/index.js')], use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env', '@babel/preset-react'] } }
- C-Dev