我尝试将'target:node'添加到webpack.dev.js,以将node_modules从我的捆绑文件中排除。这会导致错误。现在我有" Target:web",但已返回Node_modules。这是我的applicationPart的配置文件(尝试使用dllReferencePlugin(:
var path = require("path");
var webpack = require("webpack");
module.exports = {
target:'web',
devServer: {
contentBase: path.join(__dirname, "build"),
compress: true,
port: 9000
},
node: {
fs: 'empty'
},
cache: true,
devtool: "eval", //or cheap-module-eval-source-map
entry: {
app: path.join(__dirname, "client/app", "app.js")
},
output: {
path: path.join(__dirname, "buildf"),
filename: "ha.js",
chunkFilename: "[name].js"
},
plugins: [
//Typically you'd have plenty of other plugins here as well
new webpack.DllReferencePlugin({
context: path.join(__dirname, "client"),
manifest: require("./build/vendor-manifest.json")
}),
],
module: {
loaders: [
{
test: /.js?$/,
loader: "babel-loader",
include: [
path.join(__dirname, "client") //important for performance!
],
exclude: [
path.resolve(__dirname, "node_modules")
],
query: {
cacheDirectory: true, //important for performance
plugins: ["transform-regenerator"],
presets: ["es2015", "stage-0"]
}
},
{ test: /.(scss|sass)$/, loader: ['style-loader', 'css-loader', 'sass-loader'] },
{ test: /.html$/, loader: 'raw-loader' },
{ test: /.css$/, loader: 'css-loader' }
]
}
};
如何将node_modules文件夹从ha.js(app bundle(构建中排除?有关完整的代码,请参见此处
在这里一个示例:
rules: [
{
test: /.js$/,
exclude: /(node_modules)/, // <---
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]