如何在npm脚本中渲染pug(jade)到html

how can I render pug(jade) to html in npm scripts?

本文关键字:pug jade html npm 脚本      更新时间:2023-09-26

我正在尝试构建我的包。json文件,我有一个困难的时候,当它涉及到编写脚本。

"scripts": {
"test": "echo '"Error: no test specified'" && exit 1", 
"build-css":"node-sass --output-style compressed -o build/styles src/styles", 
"pugtohtml": "npm pug -D index.pug"  
},

这行不通

我已经安装了pug包,现在我想使用npm自动执行任务,你能帮我吗?如果你能给我一些关于如何学习编写脚本和使用npm自动执行任务的提示和资源,我会很感激的,谢谢!

你必须这样写任务

"pugtohtml": "pug --output-style compressed -o dist/html/ assets/pug/*.pug"

看起来命令行客户端需要在NPM脚本中使用它。

根据Pug NPM页面:

npm install pug

命令行

安装最新版本的Node.js后,使用以下命令安装:

npm install pug-cli -g


我使用npm install pug-cli --save-dev代替,因为我喜欢包安装在本地的项目,我正在工作,但是YMMV.

如果您对全局(-g)的事情感兴趣,您可能不需要pug-cli包来进行命令行处理,您可以使用这里提到的其他解决方案。