Ken
Ken

Reputation: 65

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!

Upvotes: 1

Views: 2286

Answers (2)

Ben
Ben

Reputation: 57209

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.

Upvotes: 0

Arsen Tsvetkov
Arsen Tsvetkov

Reputation: 21

You must write the task like this

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

Upvotes: 2

Related Questions