1.1.0 • Published 3 years ago

pug-plain-loader v1.1.0

Weekly downloads
83,368
License
MIT
Repository
github
Last release
3 years ago

pug-plain-loader

A loader that simply compiles pug templates into HTML.

Installation

Note pug is a peer dependency, so make sure to install both:

npm install -D pug-plain-loader pug

Usage

This loader is mostly intended to be used alongside vue-loader v15+, since it now requires using webpack loaders to handle template preprocessors. There's also pug-html-loader which unfortunately is out-of-date and not actively maintained.

If you are only using this loader for templating in single-file Vue components, simply configure it with:

{
  module: {
    rules: [
      {
        test: /\.pug$/,
        loader: 'pug-plain-loader'
      }
    ]
  }
}

This will apply this loader to all <template lang="pug"> blocks in your Vue components.

If you also intend to use it to import .pug files as HTML strings in JavaScript, you will need to chain raw-loader after this loader. Note however adding raw-loader would break the output for Vue components, so you need to have two rules, one of them excluding Vue components:

{
  module: {
    rules: [
      {
        test: /\.pug$/,
        oneOf: [
          // this applies to pug imports inside JavaScript
          {
            exclude: /\.vue$/,
            use: ['raw-loader', 'pug-plain-loader']
          },
          // this applies to <template lang="pug"> in Vue components
          {
            use: ['pug-plain-loader']
          }
        ]
      }
    ]
  }
}

Options

See Pug compiler options.

The doctype option is set to html by default, since most Vue templates are HTML fragments without explicit doctype.

An additional option data can be used to pass locals for the template, although this is typically not recommended when using in Vue components.

@thombruce/nuxt-tnt@thombruce/vue-cli-plugin-tnt@unlabel/nuxt@unlabel/vue-cli-plugin-ui@rockband/nuxt@rockband/vue-cli-plugin-uivue-trellovue-trello-type@monksoftware/bob-core-webchatsmp-library3euaaaio@dmcl/clui@dmcl/cl-uibitrix24libwclassicknight-uit10l-componentst10l-components-testmyrp-components@collaveinc/quasar-app-extension-workbench@collaveinc/workbench-nuxt-modulelg-ly-web-components@pojntfx-incubator/vuetify-mockupsfbajfs@everything-registry/sub-chunk-2492sfwikidui-clidynamodb-gui-clienteq-calendar-vue2emr-audio-playeremr-starter-packdenidedokomacartedokoma-blobdokoma-svgcartographieqd-cliscyocyo-clirecyclops-admin-dashboardrecyclops-driver-appsan-anode-loadersaber-plugin-transformer-pugsmart-elel-tree-selectorsok888888@averjs/rendererp5-vue-mirrorcecii@bkwld/cloakparaview-glance@bestcoder/best-ui@cartonesdelpacifico/dx-vue-corepoint-calendarcogearcogear-plugin-vue@chenning/v-clock@cloak-app/boilerplatepreguntas-frecuentes-alexanderpreguntas-frecuentes-viajespersonal-npm-package-derekjjnpm-traiding-vuebitrix24-vue@atlasintelligence/ui@atomspace/vuebobpackboxescmso-din-packageoligo@desco/tot@desco/vue-example-coderails-on-node-conductorqq-clidatasoledatak-vue-componentsbens_component@amjs/vue-toolsbegin-buildbasysbdp-webpack4bamboo-library@alexandrov/vue-build-devbigyanguibili-small-app@anejs/anne-webpacktest-case-basesupanity-testeva-sdkexpress-typescript-boilerplatekemomimi@etherfe/cli-plugin-vue@etherfe/cli-plugin-vue3@homerjam/ace-dev-webpack@infinitebrahmanuniverse/nolb-pug@io-arc/task-webpack-vue@io-arc/task-webpack-vue-typescript@fev/fev@flypapertech/avian@formidableforms/vue-components@getexp-labs/supanity@gluons/vue-pack-dev
1.1.0

3 years ago

1.0.0

6 years ago