This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018-present Yuxi (Evan) You
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+65
View File
@@ -0,0 +1,65 @@
# 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:
``` sh
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`](https://github.com/willyelm/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:
``` js
{
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:
``` js
{
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](https://pugjs.org/api/reference.html#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.
+14
View File
@@ -0,0 +1,14 @@
const pug = require('pug')
const loaderUtils = require('loader-utils')
module.exports = function (source) {
const options = Object.assign({
filename: this.resourcePath,
doctype: 'html',
compileDebug: this.debug || false
}, loaderUtils.getOptions(this))
const template = pug.compile(source, options)
template.dependencies.forEach(this.addDependency)
return template(options.data || {})
}
+63
View File
@@ -0,0 +1,63 @@
{
"_args": [
[
"pug-plain-loader@1.1.0",
"/home/node/nuxt"
]
],
"_development": true,
"_from": "pug-plain-loader@1.1.0",
"_id": "pug-plain-loader@1.1.0",
"_inBundle": false,
"_integrity": "sha512-1nYgIJLaahRuHJHhzSPODV44aZfb00bO7kiJiMkke6Hj4SVZftuvx6shZ4BOokk50dJc2RSFqNUBOlus0dniFQ==",
"_location": "/pug-plain-loader",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "pug-plain-loader@1.1.0",
"name": "pug-plain-loader",
"escapedName": "pug-plain-loader",
"rawSpec": "1.1.0",
"saveSpec": null,
"fetchSpec": "1.1.0"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/pug-plain-loader/-/pug-plain-loader-1.1.0.tgz",
"_spec": "1.1.0",
"_where": "/home/node/nuxt",
"author": {
"name": "Evan You",
"email": "yyx990803@gmail.com"
},
"bugs": {
"url": "https://github.com/yyx990803/pug-plain-loader/issues"
},
"dependencies": {
"loader-utils": "^1.1.0"
},
"description": "Pug to plain html loader for webpack",
"devDependencies": {
"pug": "^2.0.3"
},
"homepage": "https://github.com/yyx990803/pug-plain-loader",
"keywords": [
"pug",
"loader",
"webpack",
"plain"
],
"license": "MIT",
"main": "index.js",
"name": "pug-plain-loader",
"peerDependencies": {
"pug": "^2.0.0 || ^3.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yyx990803/pug-plain-loader.git"
},
"version": "1.1.0"
}