D2Admin 1.7

Former-commit-id: 3010ce31114fdc121006451c72f9e18306239fd2
This commit is contained in:
liyang
2019-05-07 09:26:18 +08:00
parent 46bc6ca451
commit d07d15ed8c
952 changed files with 171232 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
# Vue Filename Injector
Inject the file path of the `.vue` on `this.$options.__source`.
## Usage
`vue.config.js`:
``` js
const VueFilenameInjector = require('./path/to/vue-filename-injector')
module.exports = {
chainWebpack: config => {
// only with chainWebpack
VueFilenameInjector(config, {
propName: '__source' // default
})
}
}
```
## Relevant
https://github.com/neutrinojs/webpack-chain
https://vue-loader.vuejs.org/guide/custom-blocks.html
+2
View File
@@ -0,0 +1,2 @@
const all = require('./src/index.js')
module.exports = all
+18
View File
@@ -0,0 +1,18 @@
const { blockName } = require('./lib/config.js')
// for chainWebpack
module.exports = function(config, options) {
config.module
.rule('vue')
.use('vue-filename-injector')
.loader(require.resolve('./lib/injector.js'))
.options(options)
.after('vue-loader')
.end()
config.module
.rule('')
.resourceQuery(new RegExp(`blockType=${blockName}`))
.use('vue-filename-injector-loader')
.loader(require.resolve('./lib/loader.js'))
.end()
}
+7
View File
@@ -0,0 +1,7 @@
const defaultPropName = '__source'
const blockName = 'vue-filename-injector'
module.exports = {
defaultPropName,
blockName
}
+30
View File
@@ -0,0 +1,30 @@
const path = require('path')
const loaderUtils = require('loader-utils')
const { blockName, defaultPropName } = require('./config.js')
module.exports = function (content /*, map, meta */) {
const loaderContext = this
const {
rootContext,
resourcePath
} = loaderContext
const context = rootContext || process.cwd()
const options = loaderUtils.getOptions(loaderContext) || {}
const rawShortFilePath = path
.relative(context, resourcePath)
.replace(/^(\.\.[\/\\])+/, '')
const propName = options.propName || defaultPropName
content += `
<${blockName}>
export default function (Component) {
Component.options.${propName} = ${JSON.stringify(rawShortFilePath.replace(/\\/g, '/'))}
}
</${blockName}>
`
return content
}
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (source, map) {
this.callback(null, source, map)
}