我正在尝试使用UglifyJS来缩小我的代码,但我遇到了一些问题。 我有一个像这样的文件结构:
/deploy /assets /js ((minified file goes here)) /js script-compiled.js我想在位于我的私人文件夹中的js/script-compiled.js上运行UglifyJS,并让它在我的deploy/js (上传到我网站的js)文件夹中输出一个script.min.js文件。 这是我到目前为止的命令:
uglifyjs js/script-compiled.js --compress --mangle --screw-ie8 -o > deploy/assets/js/script.min.js这给了我这个错误:
fs.js:549 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^ TypeError: path must be a string我有点困惑。 是否可以将文件输出到其他目录? 也许这只是一个普通的Bash事情。 谢谢!
I'm trying to use UglifyJS in order to minify my code but I'm running into a bit of a problem. I have a file structure like so:
/deploy /assets /js ((minified file goes here)) /js script-compiled.jsI want to run UglifyJS on js/script-compiled.js located in my private folder and have it output a script.min.js file in my deploy/js (the js that gets uploaded to my website) folder. Here's what I have so far for my command:
uglifyjs js/script-compiled.js --compress --mangle --screw-ie8 -o > deploy/assets/js/script.min.jsWhich gives me this error:
fs.js:549 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^ TypeError: path must be a stringI'm a little confused. Is it possible to output a file to a different directory? Maybe this is just a general Bash thing. Thanks!
最满意答案
您指定了-o选项但未提供值。 来自文档 :
-o filename或--output filename - 将结果放在filename中。 如果没有给出,结果将转到标准输出(或参见下一个)。
所以要么这样做
uglifyjs ... -o deploy/assets/js/script.min.js或省略-o并重定向标准输出
uglifyjs ... > deploy/assets/js/script.min.jsYou specified the -o option but you didn't provide a value. From the docs:
-o filename or --output filename — put the result in filename. If this isn’t given, the result goes to standard output (or see next one).
So either do
uglifyjs ... -o deploy/assets/js/script.min.jsor omit -o and redirect stdout
uglifyjs ... > deploy/assets/js/script.min.js更多推荐
发布评论