mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-26 17:56:13 -04:00
feat(memo): added memo base
This commit is contained in:
parent
a40aae44ce
commit
a5953a3c42
11 changed files with 864 additions and 157 deletions
23
buildModules/memo/index.ts
Normal file
23
buildModules/memo/index.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import {Module} from '@nuxt/types'
|
||||
|
||||
interface MemoModuleOptions {
|
||||
}
|
||||
|
||||
const toolConfigModule: Module<MemoModuleOptions> = function () {
|
||||
const {extendBuild} = this
|
||||
|
||||
extendBuild((config) => {
|
||||
if (!config.module) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Failed to register the memo module.')
|
||||
return
|
||||
}
|
||||
|
||||
config.module.rules.push({
|
||||
resourceQuery: /blockType=memo/,
|
||||
loader: require.resolve('./loader.js')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default toolConfigModule
|
11
buildModules/memo/loader.js
Normal file
11
buildModules/memo/loader.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const loader = function (source, map) {
|
||||
this.callback(
|
||||
null,
|
||||
`export default function (Component) {
|
||||
Component.options.__memo = ${JSON.stringify(source)}
|
||||
}`,
|
||||
map
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = loader
|
Loading…
Add table
Add a link
Reference in a new issue