简体   繁体   English

如何在 npm 脚本中将 pug(jade) 渲染为 html?

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

I am trying to build my package.json file, and I am having a difficult time when it comes to writing scripts.我正在尝试构建我的 package.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"  
},

this doesn't work这不起作用

I've installed the pug package and now I want to automate the task using just npm can you please help me with that and I would appreciate it if you give me tips and resources of how to learn writing scripts and automating tasks using just npm, thank you!我已经安装了 pug 包,现在我想只使用 npm 自动执行任务,你能帮我解决这个问题吗?如果你给我一些关于如何使用 npm 学习编写脚本和自动执行任务的提示和资源,我将不胜感激,谢谢你!

你必须像这样写任务

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

It looks like the command line client is required to use this with NPM scripts.看起来需要命令行客户端才能将其与 NPM 脚本一起使用。

Per the Pug NPM page :根据Pug NPM 页面

Package包裹

npm install pug

Command Line命令行

After installing the latest version of Node.js, install with:安装最新版本的 Node.js 后,安装:

npm install pug-cli -g


I'm using npm install pug-cli --save-dev instead because I prefer packages to be installed local to the project I'm working on, but YMMV.我正在使用npm install pug-cli --save-dev因为我更喜欢将软件包安装在我正在处理的项目的本地,但是 YMMV。

If you're into the global ( -g ) thing, you might not need the pug-cli package for command line handling, and you could possibly use the other solutions mentioned here.如果您对全局 ( -g ) 感兴趣,则您可能不需要pug-cli包进行命令行处理,并且您可以使用此处提到的其他解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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