2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-23 02:50:34 +03:00

add build steps for CDN distribution

This commit is contained in:
Declan de Wet
2016-11-05 15:47:22 +02:00
parent 323f63fbf5
commit 761ddb0f34
5 changed files with 75 additions and 13 deletions
+14 -1
View File
@@ -46,6 +46,7 @@
- [Installation](#installation) - [Installation](#installation)
- [Yarn](#yarn) - [Yarn](#yarn)
- [NPM](#npm) - [NPM](#npm)
- [CDN](#cdn)
- [Usage](#usage) - [Usage](#usage)
- [Step 1: Preparing the plugin](#step-1-preparing-the-plugin) - [Step 1: Preparing the plugin](#step-1-preparing-the-plugin)
- [Step 2: Server Rendering (Optional)](#step-2-server-rendering-optional) - [Step 2: Server Rendering (Optional)](#step-2-server-rendering-optional)
@@ -67,7 +68,7 @@
- [`noscript` ([Object])](#noscript-object) - [`noscript` ([Object])](#noscript-object)
- [`changed` (Function)](#changed-function) - [`changed` (Function)](#changed-function)
- [How `metaInfo` is Resolved](#how-metainfo-is-resolved) - [How `metaInfo` is Resolved](#how-metainfo-is-resolved)
- [Lists of Tags](#lists-of-tags) - [Lists of Tags](#lists-of-tags)
- [Performance](#performance) - [Performance](#performance)
- [How to prevent the update on the initial page render](#how-to-prevent-the-update-on-the-initial-page-render) - [How to prevent the update on the initial page render](#how-to-prevent-the-update-on-the-initial-page-render)
- [FAQ](#faq) - [FAQ](#faq)
@@ -98,6 +99,18 @@ $ yarn add vue-meta
$ npm install vue-meta --save $ npm install vue-meta --save
``` ```
### CDN
Use the links below - if you want a previous version, check the instructions at https://unpkg.com.
<!-- start CDN generator - do **NOT** remove this comment -->
**Uncompressed:**
> https://unpkg.com/vue-meta@0.0.0/lib/vue-meta.js
**Minified:**
> https://unpkg.com/vue-meta@0.0.0/lib/vue-meta.min.js
<!-- end CDN generator - do **NOT** remove this comment -->
# Usage # Usage
## Step 1: Preparing the plugin ## Step 1: Preparing the plugin
+12 -3
View File
@@ -42,12 +42,15 @@
"rollup-plugin-node-resolve": "^2.0.0", "rollup-plugin-node-resolve": "^2.0.0",
"snazzy": "^5.0.0", "snazzy": "^5.0.0",
"standard": "^8.5.0", "standard": "^8.5.0",
"uglify-js": "^2.7.4",
"update-section": "^0.3.3",
"vue": "^2.0.3", "vue": "^2.0.3",
"vue-loader": "^9.7.0", "vue-loader": "^9.7.0",
"webpack": "beta", "webpack": "beta",
"webpack-dev-server": "beta" "webpack-dev-server": "beta"
}, },
"homepage": "https://github.com/declandewet/vue-meta", "homepage": "https://github.com/declandewet/vue-meta",
"jsnext:main": "lib/jsnext/vue-meta.js",
"keywords": [ "keywords": [
"attribute", "attribute",
"google", "google",
@@ -63,7 +66,8 @@
"vue" "vue"
], ],
"license": "MIT", "license": "MIT",
"main": "lib", "main": "lib/vue-meta.js",
"module": "lib/jsnext/vue-meta.js",
"nyc": { "nyc": {
"exclude": [ "exclude": [
"test/**/*.js" "test/**/*.js"
@@ -74,14 +78,19 @@
"type": "git" "type": "git"
}, },
"scripts": { "scripts": {
"codecov": "codecov",
"build": "rollup -c", "build": "rollup -c",
"codecov": "codecov",
"dev": "babel-node examples/server.js", "dev": "babel-node examples/server.js",
"lint": "standard --verbose | snazzy", "lint": "standard --verbose | snazzy",
"minify": "uglifyjs lib/vue-meta.js -cm --comments -o lib/vue-meta.min.js",
"postbuild": "npm run minify",
"postminify": "npm run toc",
"posttoc": "npm run update-cdn",
"prebuild": "rimraf lib", "prebuild": "rimraf lib",
"pretest": "npm run lint", "pretest": "npm run lint",
"test": "cross-env NODE_ENV=test karma start karma.conf.js", "test": "cross-env NODE_ENV=test karma start karma.conf.js",
"toc": "doctoc README.md --title '# Table of Contents'" "toc": "doctoc README.md --title '# Table of Contents'",
"update-cdn": "babel-node scripts/update-cdn.js"
}, },
"standard": { "standard": {
"globals": [ "globals": [
+15 -7
View File
@@ -3,17 +3,25 @@ import nodeResolve from 'rollup-plugin-node-resolve'
import json from 'rollup-plugin-json' import json from 'rollup-plugin-json'
import buble from 'rollup-plugin-buble' import buble from 'rollup-plugin-buble'
const pkg = require('./package.json')
export default { export default {
entry: './src/index.js', entry: './src/index.js',
format: 'umd', targets: [
dest: './lib/index.js', { dest: pkg.main, format: 'umd', moduleName: 'VueMeta' },
moduleName: 'VueMeta', { dest: pkg['jsnext:main'], format: 'es' }
],
plugins: [ plugins: [
json(), json(),
nodeResolve({ nodeResolve({ jsnext: true }),
jsnext: true
}),
commonjs(), commonjs(),
buble() buble()
] ],
banner: `
/**
* vue-meta v${pkg.version}
* (c) ${new Date().getFullYear()} Declan de Wet
* @license MIT
*/
`.replace(/ {4}/gm, '').trim()
} }
+32
View File
@@ -0,0 +1,32 @@
import { readFileSync, writeFileSync } from 'fs'
import updateSection from 'update-section'
import { name, main, version } from '../package.json'
console.log(`Updating CDN info to latest v${version} release...`)
const readmePath = './README.md'
const cdnUrl = `https://unpkg.com/${name}@${version}/${main}`
const minifiedUrl = cdnUrl.replace('.js', '.min.js')
const content = readFileSync(readmePath, 'utf-8')
const update = `
<!-- start CDN generator - do **NOT** remove this comment -->
**Uncompressed:**
> ${cdnUrl}
**Minified:**
> ${minifiedUrl}
<!-- end CDN generator - do **NOT** remove this comment -->
`.trim().replace(/ {2}/gm, '')
const updated = updateSection(
content,
update,
(line) => (/<!-- start CDN generator/).test(line),
(line) => (/<!-- end CDN generator/).test(line)
)
writeFileSync(readmePath, updated)
console.log('CDN info updated.')
+2 -2
View File
@@ -5122,7 +5122,7 @@ typedarray@~0.0.5:
version "0.0.6" version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
uglify-js@^2.6, uglify-js@~2.7.3: uglify-js, uglify-js@^2.6, uglify-js@~2.7.3:
version "2.7.4" version "2.7.4"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.7.4.tgz#a295a0de12b6a650c031c40deb0dc40b14568bd2" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.7.4.tgz#a295a0de12b6a650c031c40deb0dc40b14568bd2"
dependencies: dependencies:
@@ -5199,7 +5199,7 @@ untildify@^2.1.0:
dependencies: dependencies:
os-homedir "^1.0.0" os-homedir "^1.0.0"
update-section@^0.3.0: update-section, update-section@^0.3.0:
version "0.3.3" version "0.3.3"
resolved "https://registry.yarnpkg.com/update-section/-/update-section-0.3.3.tgz#458f17820d37820dc60e20b86d94391b00123158" resolved "https://registry.yarnpkg.com/update-section/-/update-section-0.3.3.tgz#458f17820d37820dc60e20b86d94391b00123158"