twing-render-loader

0.2.3 • Public • Published

twing-render-loader

Check Publish to NPM npm version

Installation

yarn add --dev twing-render-loader
# or
npm install --save-dev twing-render-loader

Usage

Add this to your webpack config:

module: {
  rules: [
    // ...

    {
      test: /\.twig$/i,
      loader: 'twing-render-loader',
      options: {
        environmentModule: new URL('twing.env.mjs', import.meta.url).pathname,
        // environmentModule: require.resolve('./twing.env.mjs', import.meta.url),
      },
    },

    // ...
  ],

  // ...

  plugins: [
    new WebpackHtmlPlugin({
      template: './src/index.twig',
    }),
  ],
},

Create file named 'twing.env.mjs':

/** @type {import('twing').TwingEnvironmentOptions} */
export const options = {
    debug: true,
};

/**
 * @param {import('webpack').LoaderContext<{}>} loader
 * @param {import('twing').TwingEnvironment} env
 */
export async function configure({ loader, env }) {
    env.addGlobal('mode', loader.mode);
};

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.2.30latest

Version History

VersionDownloads (Last 7 Days)Published
0.2.30
0.2.20
0.2.10
0.2.00
0.1.00

Package Sidebar

Install

npm i twing-render-loader

Weekly Downloads

0

Version

0.2.3

License

MIT

Unpacked Size

13 kB

Total Files

6

Last publish

Collaborators

  • tarik02