拿掉 build files

This commit is contained in:
2022-07-18 16:33:23 +08:00
parent 41e2287bcb
commit 3707f158a3
31953 changed files with 0 additions and 4411796 deletions
-9
View File
@@ -1,9 +0,0 @@
{
"git": {
"commitMessage": "Release v${version}",
"tagName": "v${version}"
},
"github": {
"release": true
}
}
-9
View File
@@ -1,9 +0,0 @@
The MIT License (MIT)
Copyright (c) 2016-2019 John Jeremy Leider
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 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.
-202
View File
@@ -1,202 +0,0 @@
# vuetify-loader
<p align="center">
<a href="https://www.patreon.com/kaelwd">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Become a Patron" />
</a>
</p>
## Automatic Imports
`vuetify-loader` will automatically import all Vuetify components as you use them
```js
// webpack.config.js
const { VuetifyLoaderPlugin } = require('vuetify-loader')
exports.plugins.push(
new VuetifyLoaderPlugin()
)
```
You can also provide a custom match function to import your own project's components too:
```js
// webpack.config.js
const { VuetifyLoaderPlugin } = require('vuetify-loader')
exports.plugins.push(
new VuetifyLoaderPlugin({
/**
* This function will be called for every tag used in each vue component
* It should return an array, the first element will be inserted into the
* components array, the second should be a corresponding import
*
* originalTag - the tag as it was originally used in the template
* kebabTag - the tag normalised to kebab-case
* camelTag - the tag normalised to PascalCase
* path - a relative path to the current .vue file
* component - a parsed representation of the current component
*/
match (originalTag, { kebabTag, camelTag, path, component }) {
if (kebabTag.startsWith('core-')) {
return [camelTag, `import ${camelTag} from '@/components/core/${camelTag.substring(4)}.vue'`]
}
}
})
)
```
or if you're using Vue CLI:
```js
// vue.config.js
module.exports = {
chainWebpack: config => {
config.plugin('VuetifyLoaderPlugin').tap(args => [{
match (originalTag, { kebabTag, camelTag, path, component }) {
if (kebabTag.startsWith('core-')) {
return [camelTag, `import ${camelTag} from '@/components/core/${camelTag.substring(4)}.vue'`]
}
}
}])
}
}
```
```html
<template>
<core-form>
<v-card>
...
</v-card>
</core-form>
</template>
<script>
export default {
...
}
</script>
```
Will be compiled into:
```html
<template>
<core-form>
<v-card>
...
</v-card>
</core-form>
</template>
<script>
import { VCard } from 'vuetify/lib'
import CoreForm from '@/components/core/Form.vue'
export default {
components: {
VCard,
CoreForm
},
...
}
</script>
```
## Progressive images
`vuetify-loader` can automatically generate low-res placeholders for the `v-img` component
**NOTE:** You ***must*** have [ImageMagick](https://www.imagemagick.org/script/index.php), [GraphicsMagick](http://www.graphicsmagick.org/), or [sharp](https://github.com/lovell/sharp) installed for this to work
Add `progressiveImages` to the plugin options:
```js
exports.plugins.push(
new VuetifyLoaderPlugin({
progressiveImages: true
})
)
// vue-cli
module.exports = {
chainWebpack: config => {
config.plugin('VuetifyLoaderPlugin').tap(args => [{
progressiveImages: true
}])
}
}
```
And away you go!
```html
<v-img src="@/assets/some-image.jpg"></v-img>
```
**NOTE:** The src must follow [vue-loader's transform rules](https://vue-loader.vuejs.org/guide/asset-url.html#transform-rules)
### Loops and dynamic paths
`progressiveImages` only works on static paths, for use in a loop you have to `require` the image yourself:
```html
<v-img v-for="i in 10" :src="require(`@/images/image-${i}.jpg?vuetify-preload`)" :key="i">
```
### Configuration
`progressiveImages: true` can be replaced with an object for advanced configuration
```js
new VuetifyLoaderPlugin({
progressiveImages: {
size: 12, // Use higher-resolution previews
sharp: true // Use sharp instead of ImageMagick
}
})
```
#### Options
##### `size`
Type: `Number`
Default: `9`
The minimum dimensions of the generated preview images in pixels
##### `resourceQuery`
Type: `RegExp`
Default: `/vuetify-preload/`
Override the resource qury to match v-img URLs
If you only want some images to have placeholders, add `?lazy` to the end of the request:
```html
<v-img src="@/assets/some-image.jpg?lazy"></v-img>
```
And modify the regex to match:
```js
new VuetifyLoaderPlugin({
progressiveImages: {
resourceQuery: /lazy\?vuetify-preload/
}
})
```
##### `sharp`
Type: `Boolean`
Default: `false`
Use sharp instead of GM for environments without ImageMagick. This will result in lower-quality images
##### `graphicsMagick`
Type: `Boolean`
Default: `false`
Use GraphicsMagic instead of ImageMagick
-9
View File
@@ -1,9 +0,0 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
-18
View File
@@ -1,18 +0,0 @@
# dev
> A Vue.js project
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
```
For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
-8
View File
@@ -1,8 +0,0 @@
module.exports = {
presets: [
['@babel/preset-env', {
modules: false,
targets: 'last 2 Chrome versions'
}]
]
}
-11
View File
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>dev</title>
</head>
<body>
<div id="app"></div>
<script src="/dist/build.js"></script>
</body>
</html>
-35
View File
@@ -1,35 +0,0 @@
{
"name": "dev",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "",
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"babel-loader": "^8.0.6",
"cross-env": "^7.0.0",
"css-loader": "^3.4.2",
"fibers": "^4.0.2",
"sass": "^1.25.0",
"sass-loader": "^8.0.2",
"url-loader": "^3.0.0",
"vue": "^2.6.11",
"vue-loader": "^15.8.3",
"vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.6.11",
"vuetify": "^2.2.8",
"vuetify-loader": "../",
"webpack": "^4.41.5",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.10.2"
},
"browserslist": "last 2 Chrome versions"
}
-22
View File
@@ -1,22 +0,0 @@
<template>
<v-app>
<v-container>
<v-card v-ripple>
<div style="text-align: center">
<v-img src="@/vuetify.png" style="display: inline-flex"></v-img>
</div>
<v-card-text>
<v-text-field></v-text-field>
</v-card-text>
</v-card>
</v-container>
</v-app>
</template>
<script>
export default {}
</script>
<docs>
This is the documentation for App.vue
</docs>
-7
View File
@@ -1,7 +0,0 @@
$color-pack: false;
@import '~vuetify/src/styles/styles.sass';
@each $name, $value in $utilities {
$utilities: map-merge($utilities, ($name: false));
}
-11
View File
@@ -1,11 +0,0 @@
import Vue from 'vue'
import Vuetify from 'vuetify/lib/framework'
import App from './App.vue'
Vue.use(Vuetify)
new Vue({
el: '#app',
vuetify: new Vuetify(),
render: h => h(App)
})
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

-100
View File
@@ -1,100 +0,0 @@
var path = require('path')
var webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const isProd = process.env.NODE_ENV === 'production'
function sassLoaderOptions (indentedSyntax = false) {
return {
implementation: require('sass'),
prependData: `@import "~@/_variables.scss"` + (indentedSyntax ? '' : ';'),
sassOptions: { indentedSyntax },
}
}
module.exports = {
devtool: 'source-map',
mode: isProd ? 'production' : 'development',
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules\/(?!(vuetify)\/)/
},
{
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader',
{ loader: 'sass-loader', options: sassLoaderOptions(true) }
]
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
{ loader: 'sass-loader', options: sassLoaderOptions() }
]
},
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)(\?.*)?$/,
loader: 'url-loader',
options: { limit: 8000 }
}
]
},
resolve: {
alias: {
'vue$': path.resolve(__dirname, './node_modules/vue/dist/vue.runtime.esm.js'),
'@': path.resolve(__dirname, 'src')
},
extensions: ['*', '.js', '.vue', '.json']
},
plugins: [
new VueLoaderPlugin(),
new VuetifyLoaderPlugin({
progressiveImages: true
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false
})
],
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
optimization: {
concatenateModules: false
}
}
if (isProd) {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
})
])
}
-7
View File
@@ -1,7 +0,0 @@
const VuetifyLoader = require('./loader')
const VuetifyLoaderPlugin = require('./plugin')
const ProgressiveLoaderModule = require('../progressive-loader/module')
module.exports = VuetifyLoader
module.exports.VuetifyLoaderPlugin = VuetifyLoaderPlugin
module.exports.VuetifyProgressiveModule = ProgressiveLoaderModule
-118
View File
@@ -1,118 +0,0 @@
const path = require('path')
const loaderUtils = require('loader-utils')
const compiler = require('vue-template-compiler')
const vuetifyMatcher = require('./matcher/tag')
const vuetifyAttrsMatcher = require('./matcher/attr')
const { camelize, capitalize, hyphenate, requirePeer } = require('./util')
const runtimePaths = {
installComponents: require.resolve('./runtime/installComponents'),
installDirectives: require.resolve('./runtime/installDirectives')
}
function getMatches (type, items, matches, component) {
const imports = []
items.forEach(item => {
for (const matcher of matches) {
const match = matcher(item, {
[`kebab${type}`]: hyphenate(item),
[`camel${type}`]: capitalize(camelize(item)),
path: this.resourcePath.substring(this.rootContext.length + 1),
component
})
if (match) {
imports.push(match)
break
}
}
})
imports.sort((a, b) => a[0] < b[0] ? -1 : (a[0] > b[0] ? 1 : 0))
return imports
}
function install (install, content, imports) {
if (imports.length) {
let newContent = '/* vuetify-loader */\n'
newContent += `import ${install} from ${loaderUtils.stringifyRequest(this, '!' + runtimePaths[install])}\n`
newContent += imports.map(i => i[1]).join('\n') + '\n'
newContent += `${install}(component, {${imports.map(i => i[0]).join(',')}})\n`
// Insert our modification before the HMR code
const hotReload = content.indexOf('/* hot reload */')
if (hotReload > -1) {
content = content.slice(0, hotReload) + newContent + '\n\n' + content.slice(hotReload)
} else {
content += '\n\n' + newContent
}
}
return content
}
module.exports = async function (content, sourceMap) {
this.async()
this.cacheable()
const options = {
match: [],
attrsMatch: [],
...loaderUtils.getOptions(this)
}
if (!Array.isArray(options.match)) options.match = [options.match]
if (!Array.isArray(options.attrsMatch)) options.attrsMatch = [options.attrsMatch]
options.match.push(vuetifyMatcher)
options.attrsMatch.push(vuetifyAttrsMatcher)
if (!this.resourceQuery) {
const readFile = path => new Promise((resolve, reject) => {
this.fs.readFile(path, function (err, data) {
if (err) reject(err)
else resolve(data)
})
})
this.addDependency(this.resourcePath)
const tags = new Set()
const attrs = new Set()
const file = (await readFile(this.resourcePath)).toString('utf8')
const component = compiler.parseComponent(file)
if (component.template) {
if (component.template.src) {
const externalFile = (await new Promise((resolve, reject) =>
this.resolve(path.dirname(this.resourcePath), component.template.src, (err, result) => {
if (err) reject(err)
else resolve(result)
})
))
const externalContent = (await readFile(externalFile)).toString('utf8')
component.template.content = externalContent
}
if (component.template.lang === 'pug') {
const pug = requirePeer('pug')
try {
component.template.content = pug.render(component.template.content, {filename: this.resourcePath})
} catch (err) {/* Ignore compilation errors, they'll be picked up by other loaders */}
}
compiler.compile(component.template.content, {
modules: [{
postTransformNode: node => {
if ("directives" in node) {
node.directives.forEach(({ name }) => attrs.add(name))
}
tags.add(node.tag)
}
}]
})
}
content = install.call(this, 'installComponents', content, getMatches.call(this, 'Tag', tags, options.match, component))
content = install.call(this, 'installDirectives', content, getMatches.call(this, 'Attr', attrs, options.attrsMatch, component))
}
this.callback(null, content, sourceMap)
}
-5
View File
@@ -1,5 +0,0 @@
const { directives } = require('./generator')
module.exports = function match (_, { kebabAttr, camelAttr: attr }) {
if (directives.includes(attr)) return [attr, `import ${attr} from 'vuetify/lib/directives/${kebabAttr}'`]
}
-36
View File
@@ -1,36 +0,0 @@
const Module = require('module')
const originalLoader = Module._load
const { readdirSync, statSync } = require('fs')
const { dirname, join } = require('path')
Module._load = function _load (request, parent) {
if (request.endsWith('.styl')) return
if (request.endsWith('.scss')) return
if (request.endsWith('.sass')) return
else return originalLoader(request, parent)
}
const directives = Object.keys(require('vuetify/es5/directives'))
.filter(val => val !== 'default')
const dir = dirname(require.resolve('vuetify/es5/components'))
const components = new Map()
readdirSync(dir).forEach(group => {
if (!statSync(join(dir, group)).isDirectory()) return
const component = require(`vuetify/es5/components/${group}`).default
if (component.hasOwnProperty('$_vuetify_subcomponents')) {
Object.keys(component.$_vuetify_subcomponents)
.forEach(name => components.set(name, group))
} else {
components.set(group, group)
}
})
Module._load = originalLoader
module.exports = {
directives,
components
}
-9
View File
@@ -1,9 +0,0 @@
const { components } = require('./generator')
module.exports = function match (_, { kebabTag, camelTag: tag }) {
if (!kebabTag.startsWith('v-')) return
if (components.has(tag)) {
return [tag, `import { ${tag} } from 'vuetify/lib/components/${components.get(tag)}';`]
}
}
-149
View File
@@ -1,149 +0,0 @@
const RuleSet = require('webpack/lib/RuleSet')
const progressiveLoaderModule = require('../progressive-loader/module')
let vueLoaderPath
try {
vueLoaderPath = require.resolve('vue-loader')
} catch (err) {}
function isVueLoader (use) {
return use.ident === 'vue-loader-options' ||
use.loader === 'vue-loader' ||
(vueLoaderPath && use.loader === vueLoaderPath)
}
class VuetifyLoaderPlugin {
constructor (options) {
this.options = options || {}
}
apply (compiler) {
// use webpack's RuleSet utility to normalize user rules
const rawRules = compiler.options.module.rules
const { rules } = new RuleSet(rawRules)
this.rules = rules
// find the rules that apply to vue files
const vueRules = rules.filter(rule => rule.use && rule.use.find(isVueLoader))
if (!vueRules.length) {
throw new Error(
`[VuetifyLoaderPlugin Error] No matching rule for vue-loader found.\n` +
`Make sure there is at least one root-level rule that uses vue-loader.`
)
}
vueRules.forEach(this.updateRule.bind(this))
compiler.options.module.rules = rules
}
updateRule (rule) {
if (this.options.progressiveImages) {
const vueLoaderOptions = rule.use.find(isVueLoader).options
vueLoaderOptions.compilerOptions = vueLoaderOptions.compilerOptions || {}
vueLoaderOptions.compilerOptions.modules = vueLoaderOptions.compilerOptions.modules || []
vueLoaderOptions.compilerOptions.modules.push(progressiveLoaderModule)
const imageRuleIndex = this.rules.findIndex(rule => {
return rule.resource &&
!rule.resourceQuery &&
['.png', '.jpg', '.jpeg', '.gif'].some(ext => rule.resource(ext))
})
let imageRule = this.rules[imageRuleIndex]
const options = typeof this.options.progressiveImages === 'boolean'
? undefined
: this.options.progressiveImages
if (!imageRule) {
imageRule = {
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)(\?.*)?$/,
oneOf: [
{
test: /\.(png|jpe?g|gif)$/,
resourceQuery: options ? options.resourceQuery : /vuetify-preload/,
use: [
{
loader: 'vuetify-loader/progressive-loader',
options
},
{
loader: 'url-loader',
options: { limit: 8000 }
}
]
},
{
loader: 'url-loader',
options: { limit: 8000 }
}
]
}
rules.push(imageRule)
} else {
if (Array.isArray(imageRule.use)) {
imageRule.oneOf = [
{
test: /\.(png|jpe?g|gif)$/,
resourceQuery: options ? options.resourceQuery : /vuetify-preload/,
use: [
{
loader: 'vuetify-loader/progressive-loader',
options
},
...imageRule.use
]
},
...imageRule.use
]
} else if (imageRule.loader) {
imageRule.oneOf = [
{
test: /\.(png|jpe?g|gif)$/,
resourceQuery: options ? options.resourceQuery : /vuetify-preload/,
use: [
{
loader: 'vuetify-loader/progressive-loader',
options
},
{
loader: imageRule.loader,
options: imageRule.options
}
]
},
{
loader: imageRule.loader,
options: imageRule.options
}
]
}
delete imageRule.use
delete imageRule.loader
delete imageRule.options
}
}
rule.oneOf = [
{
resourceQuery: '?',
use: rule.use
},
{
use: [
{
loader: require.resolve('./loader'),
options: {
match: this.options.match || [],
attrsMatch: this.options.attrsMatch || []
}
},
...rule.use
]
},
]
delete rule.use
}
}
module.exports = VuetifyLoaderPlugin
-19
View File
@@ -1,19 +0,0 @@
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
module.exports = function installComponents (component, components) {
var options = typeof component.exports === 'function'
? component.exports.extendOptions
: component.options
if (typeof component.exports === 'function') {
options.components = component.exports.options.components
}
options.components = options.components || {}
for (var i in components) {
options.components[i] = options.components[i] || components[i]
}
}
-19
View File
@@ -1,19 +0,0 @@
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
module.exports = function installDirectives (component, directives) {
var options = typeof component.exports === 'function'
? component.exports.extendOptions
: component.options
if (typeof component.exports === 'function') {
options.directives = component.exports.options.directives
}
options.directives = options.directives || {}
for (var i in directives) {
options.directives[i] = options.directives[i] || directives[i]
}
}
-34
View File
@@ -1,34 +0,0 @@
/**
* Stolen from Vue
* @see https://github.com/vuejs/vue/blob/52719cca/src/shared/util.js
*/
const camelizeRE = /-(\w)/g
const camelize = str => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
}
const capitalize = str => {
return str.charAt(0).toUpperCase() + str.slice(1)
}
const hyphenateRE = /\B([A-Z])/g
const hyphenate = str => {
return str.replace(hyphenateRE, '-$1').toLowerCase()
}
function requirePeer (name) {
try {
return require(name)
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') throw e
throw new Error(`Module "${name}" required by "vuetify-loader" not found.`)
}
}
module.exports = {
camelize,
capitalize,
hyphenate,
requirePeer
}
-68
View File
@@ -1,68 +0,0 @@
{
"_args": [
[
"vuetify-loader@1.6.0",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
]
],
"_from": "vuetify-loader@1.6.0",
"_id": "vuetify-loader@1.6.0",
"_inBundle": false,
"_integrity": "sha512-1bx3YeZ712dT1+QMX+XSFlP0O5k5O5Ui9ysBBmUZ9bWkAEHWZJQI9soI+qG5qmeFxUC0L9QYMCIKP0hOL/pf3Q==",
"_location": "/vuetify-loader",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "vuetify-loader@1.6.0",
"name": "vuetify-loader",
"escapedName": "vuetify-loader",
"rawSpec": "1.6.0",
"saveSpec": null,
"fetchSpec": "1.6.0"
},
"_requiredBy": [
"/@nuxtjs/vuetify"
],
"_resolved": "https://registry.npmjs.org/vuetify-loader/-/vuetify-loader-1.6.0.tgz",
"_spec": "1.6.0",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"author": "",
"bugs": {
"url": "https://github.com/vuetifyjs/vuetify-loader/issues"
},
"dependencies": {
"file-loader": "^4.0.0",
"loader-utils": "^1.2.0"
},
"description": "A Webpack plugin for treeshaking Vuetify components and more",
"devDependencies": {
"gm": "^1.23.1",
"vue": "^2.6.10",
"vue-template-compiler": "^2.6.10",
"vuetify": "^2.0.0",
"webpack": "^4.37.0"
},
"homepage": "https://github.com/vuetifyjs/vuetify-loader#readme",
"license": "MIT",
"main": "lib/index.js",
"name": "vuetify-loader",
"optionalPeerDependencies": {
"gm": "^1.23.0",
"pug": "^2.0.0",
"sharp": "^0.21.0"
},
"peerDependencies": {
"vue-template-compiler": "^2.6.10",
"vuetify": "^1.3.0 || ^2.0.0",
"webpack": "^4.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuetifyjs/vuetify-loader.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.6.0"
}
-3
View File
@@ -1,3 +0,0 @@
const loader = require('./loader')
module.exports = loader
-74
View File
@@ -1,74 +0,0 @@
const loaderUtils = require('loader-utils')
const { requirePeer } = require('../lib/util')
module.exports = function loader(contentBuffer) {
this.cacheable && this.cacheable()
const callback = this.async()
let content = contentBuffer.toString('utf8')
// image file path
const path = this.resourcePath
// user options
const config = {
sharp: false,
graphicsMagick: false,
size: 9,
...loaderUtils.getOptions(this)
}
/** @see https://github.com/zouhir/lqip-loader */
const contentIsUrlExport = /^module.exports = "data:(.*)base64,(.*)/.test(
content
)
const contentIsFileExport = /^module.exports = (.*)/.test(content)
let source = ''
if (contentIsUrlExport) {
source = content.match(/^module.exports = (.*)/)[1]
} else {
if (!contentIsFileExport) {
const fileLoader = require('file-loader')
content = fileLoader.call(this, contentBuffer)
}
source = content.match(/^module.exports = (.*);/)[1]
}
function createModule ({ data, info, type }) {
const result = {
lazySrc: `data:image/${type};base64,` + data.toString('base64'),
aspect: info.width / info.height,
}
callback(
null,
`module.exports = {src:${source},` + JSON.stringify(result).slice(1)
)
}
if (config.sharp) {
const sharpImg = requirePeer('sharp')(path)
sharpImg
.jpeg({ quality: 10 })
.resize(config.size)
.toBuffer({ resolveWithObject: true })
.then(({ data, info }) => createModule({ data, info, type: 'jpeg' }))
.catch(err => callback(err))
} else {
const gm = requirePeer('gm').subClass({ imageMagick: !config.graphicsMagick })
const extension = path.split('.').pop().toLowerCase()
if (!['gif', 'png', 'jpg', 'jpeg'].includes(extension)) {
return callback(new Error('vuetify-loader does not support this file type (' + extension + ')'))
}
gm(extension + ':' + path).size(function(err, info) {
if (err) callback(err)
else this.resize(config.size).toBuffer('gif', (err, data) => {
if (err) console.error(err)
else createModule({ data, info, type: 'gif' })
})
})
}
}
module.exports.raw = true
-36
View File
@@ -1,36 +0,0 @@
const { hyphenate } = require('../lib/util')
module.exports = {
postTransformNode: transform
}
// Modified from @vue/component-compiler-utils
function transform(node) {
const tags = ['v-img', 'v-card-media', 'v-carousel-item']
if (tags.includes(hyphenate(node.tag)) && node.attrs) {
const attr = node.attrs.find(a => a.name === 'src')
if (!attr) return
const value = attr.value
// only transform static URLs
if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
attr.value = urlToRequire(value.slice(1, -1))
}
}
return node
}
function urlToRequire(url) {
const firstChar = url.charAt(0)
if (firstChar === '.' || firstChar === '~' || firstChar === '@') {
if (firstChar === '~') {
const secondChar = url.charAt(1)
url = url.slice(secondChar === '/' ? 2 : 1)
}
return `require("${url}?vuetify-preload")`
} else {
return `"${url}"`
}
}