如何使用闭包编译器捆绑所有js文件

时间:2019-06-10 09:51:02

标签: javascript directory bundle wildcard google-closure-compiler

我正在尝试将所有.js文件捆绑在一个特定的文件夹中,但是收到“:无此类文件或目录”错误。

这是我的代码:

const ClosureCompiler = require('google-closure-compiler').jsCompiler;
const { writeFile } = require('fs');

const closureCompiler = new ClosureCompiler({
    js: 'c:/polyfill/**.js',
    js_output_file: 'bundle.js'
});

const compilerProcess = closureCompiler.run([{
    path: './',
}], (exitCode, stdOut, stdErr) => {
     writeFile(stdOut[0].path, stdOut[0].src,()=>{});
});

1 个答案:

答案 0 :(得分:0)

此路径js: 'c:/di/webapp/public/js/polyfill/**.js',似乎是错误的。如果是Windows,则通常在c:/之后,您将获得Users目录。

您可以转到文件位置,然后右键单击该文件以获取“属性”。复制Location值,并用正斜杠代替反斜杠

相关问题