Skip to content

Commit 53d0960

Browse files
committed
oss vue sfc boiler
1 parent 1ae3fca commit 53d0960

File tree

7 files changed

+3097
-0
lines changed

7 files changed

+3097
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules/
2+
/dist/

build/rollup.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import vue from "rollup-plugin-vue";
2+
import buble from "rollup-plugin-buble";
3+
import uglify from "rollup-plugin-uglify-es";
4+
import minimist from "minimist";
5+
6+
const argv = minimist(process.argv.slice(2));
7+
8+
const config = {
9+
input: "src/index.js",
10+
output: {
11+
name: "VueScrollState",
12+
exports: "named"
13+
},
14+
plugins: [
15+
vue({
16+
css: true,
17+
compileTemplate: true
18+
}),
19+
buble()
20+
]
21+
};
22+
23+
// minify browser (iife) version
24+
if (argv.format === "iife") {
25+
config.plugins.push(uglify());
26+
}
27+
28+
export default config;

examples/example-1.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div>
3+
<VueScrollState />
4+
</div>
5+
</template>
6+
7+
<script>
8+
import VueScrollState from "../src/vue-scroll-state.vue";
9+
export default {
10+
name: "Example1",
11+
data() {
12+
return {};
13+
},
14+
components: {
15+
VueScrollState
16+
}
17+
};
18+
</script>

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "vue-scroll-state",
3+
"version": "0.1.0",
4+
"description": "",
5+
"license": "MIT",
6+
"main": "dist/vue-scroll-state.umd.js",
7+
"module": "dist/vue-scroll-state.esm.js",
8+
"unpkg": "dist/vue-scroll-state.min.js",
9+
"browser": {
10+
"./sfc": "src/vue-scroll-state.vue"
11+
},
12+
"scripts": {
13+
"dev": "vue serve ./src/vue-scroll-state.vue",
14+
"example": "vue serve ./examples/example-1.vue",
15+
"build": "npm run build:unpkg & npm run build:es & npm run build:umd",
16+
"build:umd": "rollup --config build/rollup.config.js --format umd --file dist/vue-scroll-state.umd.js",
17+
"build:es": "rollup --config build/rollup.config.js --format es --file dist/vue-scroll-state.esm.js",
18+
"build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/vue-scroll-state.min.js"
19+
},
20+
"dependencies": {},
21+
"devDependencies": {
22+
"minimist": "^1.2.0",
23+
"rollup": "^0.57.1",
24+
"rollup-plugin-buble": "^0.19.2",
25+
"rollup-plugin-uglify-es": "0.0.1",
26+
"rollup-plugin-vue": "^3.0.0",
27+
"vue": "^2.5.16",
28+
"vue-template-compiler": "^2.5.16"
29+
}
30+
}

src/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import component from "./vue-scroll-state.vue";
2+
3+
// install function executed by Vue.use()
4+
export function install(Vue) {
5+
if (install.installed) return;
6+
install.installed = true;
7+
Vue.component("VueScrollState", component);
8+
}
9+
10+
// create module definition for Vue.use()
11+
const plugin = {
12+
install
13+
};
14+
15+
// auto-install when vue is found
16+
let GlobalVue = null;
17+
if (typeof window !== "undefined") {
18+
GlobalVue = window.Vue;
19+
} else if (typeof global !== "undefined") {
20+
GlobalVue = global.Vue;
21+
}
22+
if (GlobalVue) {
23+
GlobalVue.use(plugin);
24+
}
25+
26+
export default component;

src/vue-scroll-state.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
export default {
3+
name: "VueScrollState",
4+
data() {
5+
return {};
6+
}
7+
};
8+
</script>
9+
10+
<template>
11+
<div class="vue-scroll-state">
12+
hello world
13+
</div>
14+
</template>
15+
16+
<style scoped>
17+
</style>

0 commit comments

Comments
 (0)