简体   繁体   中英

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.

"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!

你必须像这样写任务

"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.

Per the Pug NPM page :

Package

npm install pug

Command Line

After installing the latest version of Node.js, install with:

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.

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.

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