nunjucks-encore
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Nunjucks Encore

Build NPM Version NPM Downloads

Nunjucks extension for using Webpack Encore. With this extension, you can include CSS, JavaScript and assets in your Nunjucks templates.

How to install it?

$ npm install nunjucks-encore

How to use it?

import { EncoreExtension } from 'nunjucks-encore';

env.addExtension(
  'encore-extension',
  new EncoreExtension({
    entrypointsFilename: 'path/to/entrypoints.json',
    manifestFilename: 'path/to/manifest.json',
  }),
);

The extension adds the tags encore_entry_link_tags, encore_entry_script_tags and asset to Nunjucks.

Encore entry link tags

You can add CSS files to your template with the encore_entry_link_tags tag. The extension will render the whole <link> tag.

<html>
  <head>
    {% encore_entry_link_tags('entry1', 'entry2') %}
  </head>
  <body></body>
</html>

Encore entry script tags

You can add JS files to your template with the encore_entry_script_tags tag. The extension will render the whole <script> tag.

<html>
<head>
</head>
<body>
  {% encore_entry_script_tags('entry1', 'entry2') %}
</body>
</html>

Assets

You can add asset files to your template with the asset tag:

<img src="{% asset('images/image1.png') %}" />

Package Sidebar

Install

npm i nunjucks-encore

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

51.1 kB

Total Files

7

Last publish

Collaborators

  • mgascoyne