Package Exports
- posthtml-loader
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (posthtml-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Loader for PostHTML
Install
(sudo) npm i -D posthtml-loader
Usage
Setup
// webpack.config.js
module: {
loaders: [
{
test: /\.html$/,
loader: 'html!posthtml'
},
]
},
posthtml: function () {
return {
defaults: [ PostHTML Plugins ]
// Add our own Plugin Packs
}
}
Options
module.exports = {
module: {
loaders: [
{
test: /\.html$/,
loader: 'html!posthtml?pack=html'
}
{
test: /\.svg$/,
loader: 'svg!posthtml?pack=svg'
}
]
},
posthtml: function () {
return {
defaults: [],
html: [ PostHTML Plugins ],
svg: [ PostHTML Plugins ]
}
}
}
Extract
var ExtractText = require('extract-text-webpack-plugin')
module.exports = {
module: {
loaders: [
{
test: /\.html$/,
loader: ExtractText.extract('html!posthtml')
}
]
},
posthtml: function () {
return {
defaults: [ PostHTML Plugins ]
}
},
plugins: [
new ExtractText('file.html')
]
}
Integration
Templates
EJS
{ test: /\.ejs$/, loader: 'html!posthtml!ejs-html' }
Jade
{ test: /\.jade$/, loader: 'html!posthtml!jade-html' }
Templates supported by consolidate
{ test: /\.hbs$/, loader: 'html!posthtml!template-html?engine=handlebars' }
String
HTML
{ test: /\.html$/, loader: 'html!posthtml' }
SVG
{ test: /\.svg$/, loader: 'svg!posthtml' }
XML
{ test: /\.xml$/, loader: 'xml!posthtml' }
File
HTML
{ test: /\.html$/, loader: 'file?name=[name].[ext]!val!html!posthtml' }
SVG
{ test: /\.svg$/, loader: 'file?name=[name].[ext]!val!svg!posthtml' }
DOM
HTML
{ test: /\.html$/, loader: 'dom!html!posthtml' }
SVG
{ test: /\.svg$/, loader: 'dom!svg!posthtml' }