Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added in menu Pug plugin for Webpack #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

webdiscus
Copy link

Motivation

A link to a new very useful Pug plugin for Webpack has been added to the menu. This plugin is unique and has no alternative.

Pug Plugin enable to use Pug files in Webpack entry and generates HTML files that contain the hashed output JS and CSS filenames whose source files are specified in the Pug template.

This plugin makes it very easy to use Pug templates with Webpack without complexe configuration.

webpack.config.js

const PugPlugin = require('pug-plugin');
module.exports = {
  entry: {
    index: './src/views/home/index.pug',  // output dist/index.html
    about: './src/views/about/index.pug', // output dist/about.html
  },
  plugins: [
    new PugPlugin(), // enable processing of Pug files specified in Webpack entry
  ],
  module: {
    rules: [
      {
        test: /.pug$/,
        loader: PugPlugin.loader, // Pug loader
      },
    ],
  },
};

Add source scripts and styles directly to Pug using require():

html
  head
    link(href=require('./styles.scss') rel='stylesheet')
    script(src=require('./main.js'))
  body
    h1 Hello Pug!

Generated HTML contains hashed CSS and JS output filenames:

<html>
  <head>
    <link href="/assets/css/styles.05e4dd86.css" rel="stylesheet">
    <script src="/assets/js/main.f4b855d8.js"></script>
  </head>
  <body>
    <h1>Hello Pug!</h1>
  <body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant