简体   繁体   中英

How to use Piler with standard HTML instead of Jade?

I am using Node.js with Piler ( https://github.com/epeli/piler ). The example at the project website shows how to use Piler with an index.jade file.

index.jade:

!!! 5
html
  head
    !{css}
    !{js}
  body
    h1 Hello Piler

The !{css} and !{js} tags will translate to the corresponding html tags when the index file gets delivered to the client.

For example : <script type="text/javascript" src="myscript.js"></script>

How can I use Piler without an index.jade file but instead with an index.html file? What are the !{css} and !{js} tags supposed to look like in the index.html?

With other words: I don't want to use Piler with Jade but instead with standard html.

Thanks in advance.

Piler by default stores concat versions of the js and css in the piler cache directory which you can specify by passing the outputDirectory parameter when creating your JS/CSS Manager.

pilerCachePath = '/www/your-project/public-path/assets/';
var clientjs = piler.createJSManager({outputDirectory: pilerCachePath});
var clientcss = piler.createCSSManager({outputDirectory: pilerCachePath});

You can define a public path that you can access and then in your html, just use these paths

<!-- ... -->
<link rel="stylesheet" type="text/css" href="/assets/global.css">
</head>
<body>
<!-- ... -->
<script type="text/javascript" src="/assets/global.js"></script>
</body>

However, i would recommend to use gruntjs for that purpose. Their documentation has a very good introduction on how to use it.

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