Webpack 为文件夹中的每个文件创建单独的网页包包
我想为我的Webpack 为文件夹中的每个文件创建单独的网页包包,webpack,webpack-config,Webpack,Webpack Config,我想为我的/tests目录中的每个.ts文件创建一个单独的包。 我当前手动列出所有文件: // webpack.config.js entry: { test1: "./src/tests/test1.ts", test2: "./src/tests/test2.ts", }, output: { filename: "[name].bundle.js" }, // resultes in `dist/test1.bundl
/tests
目录中的每个.ts
文件创建一个单独的包。
我当前手动列出所有文件:
// webpack.config.js
entry: {
test1: "./src/tests/test1.ts",
test2: "./src/tests/test2.ts",
},
output: {
filename: "[name].bundle.js"
},
// resultes in `dist/test1.bundle.js` and `dist/test2.bundle.js`
但我希望它能自动发生。我试着按照中的建议使用
也像这样(我在别处发现):
但这两种方法都不适用于我——每次只创建main.bundle.js
可能的原因是什么
我的完整网页包配置:
const path = require("path");
const glob = require("glob");
module.exports = {
resolve: {
extensions: [".ts", ".js"]
},
mode: "development",
entry: glob.sync("./src/tests/*.ts"),
output: {
path: path.resolve(__dirname, "dist"),
libraryTarget: "commonjs",
filename: "[name].bundle.js"
},
module: {
rules: [
{
test: /\.ts$/,
loader: "babel-loader",
options: {
presets: [["@babel/typescript"]],
plugins: [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
}
}
]
},
stats: { colors: true },
externals: /k6(\/.*)?/,
devtool: "source-map"
};
entry: glob.sync("./src/tests/*.ts")
const path = require("path");
const glob = require("glob");
module.exports = {
resolve: {
extensions: [".ts", ".js"]
},
mode: "development",
entry: glob.sync("./src/tests/*.ts"),
output: {
path: path.resolve(__dirname, "dist"),
libraryTarget: "commonjs",
filename: "[name].bundle.js"
},
module: {
rules: [
{
test: /\.ts$/,
loader: "babel-loader",
options: {
presets: [["@babel/typescript"]],
plugins: [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
}
}
]
},
stats: { colors: true },
externals: /k6(\/.*)?/,
devtool: "source-map"
};