简体   繁体   中英

How to bundle all js files using closure-compiler

I am trying to bundle all .js files in a specific folder, but receive a ': no such file or directory' error.

Here is my code:

 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,()=>{}); }); 

It seem this path js: 'c:/di/webapp/public/js/polyfill/**.js', is wrong.If it is windows then normally after c:/ you will get the Users directory.

You can go to the file location and right click on that to get the 'Properties' . Copy Location value and replace the backward slash with forward

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM