Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在webpack 2条目中指定完整的子目录_Javascript_Typescript_Webpack_Webpack 2 - Fatal编程技术网

Javascript 在webpack 2条目中指定完整的子目录

Javascript 在webpack 2条目中指定完整的子目录,javascript,typescript,webpack,webpack-2,Javascript,Typescript,Webpack,Webpack 2,我有一个webpack 2配置,如下所示: module.exports = { context: __dirname, entry: [ "./app.ts", "./tab.ts", "./client/clientService.ts", "./client/clientSearchComponent.ts", "./infrastructure/messageComponent.ts",

我有一个webpack 2配置,如下所示:

module.exports = {
    context: __dirname,
    entry: [
        "./app.ts",
        "./tab.ts",
        "./client/clientService.ts",
        "./client/clientSearchComponent.ts",
        "./infrastructure/messageComponent.ts",
        "./infrastructure/typeaheadComponent.ts",
        "./url.ts"],
    output: {
        filename: "./wwwroot/js/admin/admin.js"
    },
    devtool: "source-map",
    module: {
        rules: [
            { test: /\.ts$/, use: 'ts-loader' }
        ]
    }
};
这将导入到一个gulp任务中,如下所示

gulp.task("admin:js",
    function (done) {
        var configuration = require(path.join(__dirname, config.js, "admin/webpack.config.js").toString());
        webpack(configuration).run(reportWebpackResults(done));
    });
我发现我必须在
条目[…]中指定每个组件

如何指定glob,它们似乎不是开箱即用的

entry: [
    "./client/**/*.ts", // module not found...

您可以使用像这样的全局库
globle.find
返回一个文件数组。因此,您可以将其用作条目:

entry: globule.find("./client/**/*.ts")
如果还想包括其他入口点,可以通过分散返回的数组来组合它们:

entry: [
    './other/entry.js'
    ...globule.find("./client/**/*.ts")
]
或使用组合阵列的任何其他方式(例如)

或者,您可以使用单个条目,在问题中所示的帮助下导入所需的所有内容

const req = require.context('./client/', true, /\.ts$/);
req.keys().forEach(req);