develop
HerrHase 1 year ago
parent 5b5ea003e6
commit 9104d0c702

@ -1,9 +1,9 @@
MIT License MIT License
Copyright (c) <year> <copyright holders> Copyright (c) 2022 Björn Hase <me@herr-hase.wtf>
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: 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 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. 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.

@ -13,4 +13,22 @@ i had development a CMS that runs on Markdown File a few years ago as a proof of
``` ```
npm install @node001/happy-site-webpack-plugin --save-dev npm install @node001/happy-site-webpack-plugin --save-dev
``` ```
## Markdown Files
```
---
title: "health goth DIY tattooed"
view: "home.njk"
meta:
description: "La"
media:
teaser:
src: "_images/test.jpeg"
alt: "cold-pressed"
---
```
## Block Files

@ -1,24 +1,61 @@
import { validate } from 'schema-utils' import { validate } from 'schema-utils'
import HappySite from './src/happySite.js'
// schema for options object // schema for options object
const schema = { const schema = {
type: 'object', type: 'object',
properties: { properties: {
test: { source: {
type: 'string', type: 'string'
},
destination: {
type: 'string'
},
views: {
type: 'string'
} }
} }
} }
export default class HappySiteWebpackPlugin { export default class HappySiteWebpackPlugin {
constructor(options = {}) { constructor(options = {}) {
validate(schema, options, { validate(schema, options)
name: 'Hello World Plugin',
baseDataPath: 'options', this._options = options
})
} }
apply(compiler) { apply(compiler) {
const pluginName = HappySiteWebpackPlugin.name
// webpack module instance can be accessed from the compiler object,
// this ensures that correct version of the module is used
// (do not require/import the webpack or any symbols from it directly).
const { webpack } = compiler
// Compilation object gives us reference to some useful constants.
const { Compilation } = webpack
// RawSource is one of the "sources" classes that should be used
// to represent asset sources in compilation.
const { RawSource } = webpack.sources
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
// Tapping to the assets processing pipeline on a specific stage.
compilation.hooks.processAssets.tap({
name: pluginName,
// Using one of the later asset processing stages to ensure
// that all assets were already added to the compilation by other plugins.
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
},
(assets) => {
const happySite = new HappySite(this._options.source, this._options.destination, this._views)
})
})
} }
} }
module.exports = { HappySiteWebpackPlugin }
Loading…
Cancel
Save