Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 674700c

Browse files
committed
chore: Add cookbook examples
1 parent b63e4b6 commit 674700c

24 files changed

+555
-29
lines changed

cookbook/extract-css/package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"build": "rollup -c --environment BUILD:production"
5+
},
6+
"main": "./dist/MyComponent.js",
7+
"style": "./dist/MyComponent.css",
8+
"devDependencies": {
9+
"rollup": "^0.59.4",
10+
"rollup-plugin-css-only": "^0.4.0",
11+
"rollup-plugin-vue": "link:../.."
12+
}
13+
}

cookbook/extract-css/rollup.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import vue from 'rollup-plugin-vue'
2+
import css from 'rollup-plugin-css-only'
3+
4+
export default {
5+
input: 'src/MyComponent.vue',
6+
output: {
7+
format: 'esm',
8+
file: 'dist/MyComponent.js'
9+
},
10+
plugins: [
11+
css(),
12+
vue({ css: false })
13+
]
14+
}

cookbook/extract-css/shrinkwrap.yaml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
devDependencies:
2+
rollup: 0.59.4
3+
rollup-plugin-css-only: 0.4.0
4+
rollup-plugin-vue: 'link:../..'
5+
packages:
6+
/@types/estree/0.0.39:
7+
dev: true
8+
resolution:
9+
integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
10+
/@types/node/10.3.1:
11+
dev: true
12+
resolution:
13+
integrity: sha512-IsX9aDHDzJohkm3VCDB8tkzl5RQ34E/PFA29TQk6uDGb7Oc869ZBtmdKVDBzY3+h9GnXB8ssrRXEPVZrlIOPOw==
14+
/balanced-match/1.0.0:
15+
dev: true
16+
resolution:
17+
integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
18+
/brace-expansion/1.1.11:
19+
dependencies:
20+
balanced-match: 1.0.0
21+
concat-map: 0.0.1
22+
dev: true
23+
resolution:
24+
integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
25+
/concat-map/0.0.1:
26+
dev: true
27+
resolution:
28+
integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
29+
/estree-walker/0.2.1:
30+
dev: true
31+
resolution:
32+
integrity: sha1-va/oCVOD2EFNXcLs9MkXO225QS4=
33+
/minimatch/3.0.4:
34+
dependencies:
35+
brace-expansion: 1.1.11
36+
dev: true
37+
resolution:
38+
integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
39+
/minimist/0.0.8:
40+
dev: true
41+
resolution:
42+
integrity: sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
43+
/mkdirp/0.5.1:
44+
dependencies:
45+
minimist: 0.0.8
46+
dev: true
47+
resolution:
48+
integrity: sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
49+
/rollup-plugin-css-only/0.4.0:
50+
dependencies:
51+
mkdirp: 0.5.1
52+
rollup-pluginutils: 1.5.2
53+
dev: true
54+
resolution:
55+
integrity: sha512-a9hhQnwajgrVEyyp+QPvOyV5QC9AN6PILO4Teg2+MCKTZgYAQkZy4B1pYjAuMOH9qgyFiJY8hAu6CEVIDU5Zjw==
56+
/rollup-pluginutils/1.5.2:
57+
dependencies:
58+
estree-walker: 0.2.1
59+
minimatch: 3.0.4
60+
dev: true
61+
resolution:
62+
integrity: sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=
63+
/rollup/0.59.4:
64+
dependencies:
65+
'@types/estree': 0.0.39
66+
'@types/node': 10.3.1
67+
dev: true
68+
resolution:
69+
integrity: sha512-ISiMqq/aJa+57QxX2MRcvLESHdJ7wSavmr6U1euMr+6UgFe6KM+3QANrYy8LQofwhTC1I7BcAdlLnDiaODs1BA==
70+
registry: 'https://registry.npmjs.org/'
71+
shrinkwrapMinorVersion: 7
72+
shrinkwrapVersion: 3
73+
specifiers:
74+
rollup: ^0.59.4
75+
rollup-plugin-css-only: ^0.4.0
76+
rollup-plugin-vue: 'link:../..'
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<h1>Hello {{ name }}</h1>
3+
</template>
4+
5+
<script>
6+
export default {
7+
data() {
8+
return { name: 'Jane Doe' }
9+
}
10+
}
11+
</script>
12+
13+
<style scoped>
14+
h1 {
15+
color: red;
16+
}
17+
</style>

cookbook/library/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"build": "rollup -c --environment BUILD:production"
5+
},
6+
"main": "./dist/MyComponent.ssr.js",
7+
"module": "./dist/MyComponent.esm.js",
8+
"browser": "./dist/MyComponent.js",
9+
"unpkg": "./dist/MyComponent.js",
10+
"devDependencies": {
11+
"rollup": "^0.59.4",
12+
"rollup-plugin-css-only": "^0.4.0",
13+
"rollup-plugin-vue": "link:../.."
14+
}
15+
}

cookbook/library/rollup.config.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import vue from 'rollup-plugin-vue'
2+
3+
export default [
4+
// ESM build to be used with webpack/rollup.
5+
{
6+
input: 'src/MyComponent.vue',
7+
output: {
8+
format: 'esm',
9+
file: 'dist/MyComponent.esm.js'
10+
},
11+
plugins: [
12+
vue()
13+
]
14+
},
15+
// SSR build.
16+
{
17+
input: 'src/MyComponent.vue',
18+
output: {
19+
format: 'cjs',
20+
file: 'dist/MyComponent.ssr.js'
21+
},
22+
plugins: [
23+
vue({ template: { optimizeSSR: true } })
24+
]
25+
},
26+
// Browser build.
27+
{
28+
input: 'src/wrapper.js',
29+
output: {
30+
format: 'iife',
31+
file: 'dist/MyComponent.js'
32+
},
33+
plugins: [
34+
vue()
35+
]
36+
}
37+
]

cookbook/library/shrinkwrap.yaml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
devDependencies:
2+
rollup: 0.59.4
3+
rollup-plugin-css-only: 0.4.0
4+
rollup-plugin-vue: 'link:../..'
5+
packages:
6+
/@types/estree/0.0.39:
7+
dev: true
8+
resolution:
9+
integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
10+
/@types/node/10.3.0:
11+
dev: true
12+
resolution:
13+
integrity: sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA==
14+
/balanced-match/1.0.0:
15+
dev: true
16+
resolution:
17+
integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
18+
/brace-expansion/1.1.11:
19+
dependencies:
20+
balanced-match: 1.0.0
21+
concat-map: 0.0.1
22+
dev: true
23+
resolution:
24+
integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
25+
/concat-map/0.0.1:
26+
dev: true
27+
resolution:
28+
integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
29+
/estree-walker/0.2.1:
30+
dev: true
31+
resolution:
32+
integrity: sha1-va/oCVOD2EFNXcLs9MkXO225QS4=
33+
/minimatch/3.0.4:
34+
dependencies:
35+
brace-expansion: 1.1.11
36+
dev: true
37+
resolution:
38+
integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
39+
/minimist/0.0.8:
40+
dev: true
41+
resolution:
42+
integrity: sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
43+
/mkdirp/0.5.1:
44+
dependencies:
45+
minimist: 0.0.8
46+
dev: true
47+
resolution:
48+
integrity: sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
49+
/rollup-plugin-css-only/0.4.0:
50+
dependencies:
51+
mkdirp: 0.5.1
52+
rollup-pluginutils: 1.5.2
53+
dev: true
54+
resolution:
55+
integrity: sha512-a9hhQnwajgrVEyyp+QPvOyV5QC9AN6PILO4Teg2+MCKTZgYAQkZy4B1pYjAuMOH9qgyFiJY8hAu6CEVIDU5Zjw==
56+
/rollup-pluginutils/1.5.2:
57+
dependencies:
58+
estree-walker: 0.2.1
59+
minimatch: 3.0.4
60+
dev: true
61+
resolution:
62+
integrity: sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=
63+
/rollup/0.59.4:
64+
dependencies:
65+
'@types/estree': 0.0.39
66+
'@types/node': 10.3.0
67+
dev: true
68+
resolution:
69+
integrity: sha512-ISiMqq/aJa+57QxX2MRcvLESHdJ7wSavmr6U1euMr+6UgFe6KM+3QANrYy8LQofwhTC1I7BcAdlLnDiaODs1BA==
70+
registry: 'https://registry.npmjs.org/'
71+
shrinkwrapMinorVersion: 7
72+
shrinkwrapVersion: 3
73+
specifiers:
74+
rollup: ^0.59.4
75+
rollup-plugin-css-only: ^0.4.0
76+
rollup-plugin-vue: 'link:../..'

cookbook/library/src/MyComponent.vue

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<h1>Hello {{ name }}</h1>
3+
</template>
4+
5+
<script>
6+
export default {
7+
data() {
8+
return { name: 'Jane Doe' }
9+
}
10+
}
11+
</script>
12+
13+
<style scoped>
14+
h1 {
15+
color: red;
16+
}
17+
</style>

cookbook/library/src/wrapper.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import MyComponent from './MyComponent.vue'
2+
3+
if (typeof Vue !== 'undefined') {
4+
Vue.component('MyComponent', MyComponent)
5+
}

cookbook/minimal/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"scripts": {
44
"build": "rollup -c --environment BUILD:production"
55
},
6-
"main": "./dist/my-component.esm.js",
6+
"main": "./dist/MyComponent.js",
77
"devDependencies": {
88
"rollup": "^0.59.4",
99
"rollup-plugin-vue": "link:../.."

cookbook/minimal/rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
input: 'src/MyComponent.vue',
55
output: {
66
format: 'esm',
7-
file: 'dist/my-component.esm.js'
7+
file: 'dist/MyComponent.js'
88
},
99
plugins: [
1010
vue()

cookbook/ssr/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"build": "rollup -c --environment BUILD:production"
5+
},
6+
"main": "./dist/MyComponent.js",
7+
"devDependencies": {
8+
"rollup": "^0.59.4",
9+
"rollup-plugin-vue": "link:../.."
10+
}
11+
}

cookbook/ssr/rollup.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import vue from 'rollup-plugin-vue'
2+
3+
export default {
4+
input: 'src/MyComponent.vue',
5+
output: {
6+
format: 'esm',
7+
file: 'dist/MyComponent.js'
8+
},
9+
plugins: [
10+
vue({ template: { optimizeSSR: true } })
11+
]
12+
}

cookbook/ssr/shrinkwrap.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
devDependencies:
2+
rollup: 0.59.4
3+
rollup-plugin-vue: 'link:../..'
4+
packages:
5+
/@types/estree/0.0.39:
6+
dev: true
7+
resolution:
8+
integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
9+
/@types/node/10.3.0:
10+
dev: true
11+
resolution:
12+
integrity: sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA==
13+
/rollup/0.59.4:
14+
dependencies:
15+
'@types/estree': 0.0.39
16+
'@types/node': 10.3.0
17+
dev: true
18+
resolution:
19+
integrity: sha512-ISiMqq/aJa+57QxX2MRcvLESHdJ7wSavmr6U1euMr+6UgFe6KM+3QANrYy8LQofwhTC1I7BcAdlLnDiaODs1BA==
20+
registry: 'https://registry.npmjs.org/'
21+
shrinkwrapMinorVersion: 7
22+
shrinkwrapVersion: 3
23+
specifiers:
24+
rollup: ^0.59.4
25+
rollup-plugin-vue: 'link:../..'

cookbook/ssr/src/MyComponent.vue

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<h1>Hello {{ name }}</h1>
3+
</template>
4+
5+
<script>
6+
export default {
7+
data() {
8+
return { name: 'Jane Doe' }
9+
}
10+
}
11+
</script>
12+
13+
<style scoped>
14+
h1 {
15+
color: red;
16+
}
17+
</style>
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"build": "rollup -c --environment BUILD:production"
5+
},
6+
"main": "./dist/MyComponent.js",
7+
"devDependencies": {
8+
"rollup": "^0.59.4",
9+
"rollup-plugin-typescript": "^0.8.1",
10+
"rollup-plugin-vue": "link:../.."
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import vue from 'rollup-plugin-vue'
2+
import typescript from 'rollup-plugin-typescript'
3+
4+
export default {
5+
input: 'src/MyComponent.vue',
6+
output: {
7+
format: 'esm',
8+
file: 'dist/MyComponent.js'
9+
},
10+
external: ['vue'],
11+
plugins: [
12+
typescript({
13+
tsconfig: false,
14+
experimentalDecorators: true,
15+
module: 'es2015'
16+
}),
17+
vue()
18+
]
19+
}

0 commit comments

Comments
 (0)