-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f9bae6f
Showing
9 changed files
with
249 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Vue Filename Injector | ||
|
||
Inject the file path of the `.vue` on `this.$options.__source`. | ||
|
||
## Install | ||
|
||
``` sh | ||
yarn add @d2-projects/vue-filename-injector -D | ||
``` | ||
|
||
or | ||
|
||
``` sh | ||
npm install @d2-projects/vue-filename-injector -D | ||
``` | ||
|
||
## Usage | ||
|
||
Only used for vue-cli3, `vue.config.js`: | ||
|
||
``` js | ||
const VueFilenameInjector = require('@d2-projects/vue-filename-injector') | ||
|
||
module.exports = { | ||
|
||
chainWebpack: config => { | ||
// ... | ||
|
||
// in here, only with chainWebpack | ||
VueFilenameInjector(config, { | ||
propName: '__source' // default | ||
}) | ||
|
||
} | ||
} | ||
``` | ||
|
||
## Relevant | ||
|
||
https://github.com/neutrinojs/webpack-chain | ||
https://vue-loader.vuejs.org/guide/custom-blocks.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./src/index.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "@d2-projects/vue-filename-injector", | ||
"version": "1.0.0", | ||
"description": "Inject the file path of .vue", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/d2-projects/vue-filename-injector.git" | ||
}, | ||
"keywords": [ | ||
"vue", | ||
"file", | ||
"filename", | ||
"path", | ||
"injector", | ||
"loader" | ||
], | ||
"author": "CNine <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/d2-projects/vue-filename-injector/issues" | ||
}, | ||
"homepage": "https://github.com/d2-projects/vue-filename-injector#readme", | ||
"dependencies": { | ||
"loader-utils": "^1.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const defaultPropName = '__source' | ||
const blockName = 'vue-filename-injector' | ||
|
||
module.exports = { | ||
defaultPropName, | ||
blockName | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function(source, map) { | ||
this.callback(null, source, map) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
big.js@^5.2.2: | ||
version "5.2.2" | ||
resolved "https://registry.npm.taobao.org/big.js/download/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" | ||
integrity sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg= | ||
|
||
emojis-list@^2.0.0: | ||
version "2.1.0" | ||
resolved "https://registry.npm.taobao.org/emojis-list/download/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" | ||
integrity sha1-TapNnbAPmBmIDHn6RXrlsJof04k= | ||
|
||
json5@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.npm.taobao.org/json5/download/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" | ||
integrity sha1-d5+wAYYE+oVOrL9iUhgNg1Q+Pb4= | ||
dependencies: | ||
minimist "^1.2.0" | ||
|
||
loader-utils@^1.2.3: | ||
version "1.2.3" | ||
resolved "https://registry.npm.taobao.org/loader-utils/download/loader-utils-1.2.3.tgz#1ff5dc6911c9f0a062531a4c04b609406108c2c7" | ||
integrity sha1-H/XcaRHJ8KBiUxpMBLYJQGEIwsc= | ||
dependencies: | ||
big.js "^5.2.2" | ||
emojis-list "^2.0.0" | ||
json5 "^1.0.1" | ||
|
||
minimist@^1.2.0: | ||
version "1.2.0" | ||
resolved "https://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fminimist%2Fdownload%2Fminimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" | ||
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= |