问题描述
我想为我的.ts
目录中的每个/tests
文件创建一个单独的捆绑包。
我目前手动列出了所有文件:
// 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`
中的建议利用this answer
entry: {
js: glob.sync("./src/tests/*.ts"),}
并且也这样(我在其他地方找到了):
entry: glob.sync("./src/tests/*.ts")
但对我都不起作用-每次只会创建main.bundle.js
。
可能是什么原因?
我的完整Webpack配置:
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"
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)