-
Notifications
You must be signed in to change notification settings - Fork 100
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
1 parent
d6302ea
commit 70b6f0b
Showing
19 changed files
with
1,634 additions
and
79 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
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 @@ | ||
var fs = require('fs') | ||
var cssnano = require('cssnano').process | ||
var resolve = require('path').resolve | ||
var postcss = require('postcss') | ||
|
||
var file = 'vuep.css' | ||
var processor = postcss([require('postcss-salad')]) | ||
|
||
var save = function (file, content) { | ||
fs.writeFileSync(resolve(__dirname, '../dist/', file), content) | ||
} | ||
var load = function (file) { | ||
return fs.readFileSync(resolve(__dirname, '../src/style/', file)).toString() | ||
} | ||
var loadDist = function (file) { | ||
return fs.readFileSync(resolve(__dirname, '../dist/', file)).toString() | ||
} | ||
|
||
processor.process(load(file), { from: resolve(__dirname, '../src/style/', file) }) | ||
.then(function (result) { | ||
save(file, result.css) | ||
console.log('salad - ' + file) | ||
cssnano(loadDist(file)) | ||
.then(function (result) { | ||
save('vuep.min.css', result.css) | ||
console.log('cssnao - ' + file) | ||
}) | ||
}).catch(function (err) { | ||
console.log(err) | ||
}) |
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,51 @@ | ||
var rollup = require('rollup') | ||
var buble = require('rollup-plugin-buble') | ||
var commonjs = require('rollup-plugin-commonjs') | ||
var nodeResolve = require('rollup-plugin-node-resolve') | ||
var uglify = require('rollup-plugin-uglify') | ||
|
||
var build = function (opts) { | ||
rollup | ||
.rollup({ | ||
entry: 'src/' + opts.entry, | ||
plugins: [buble(), commonjs(), nodeResolve()].concat(opts.plugins || []), | ||
external: opts.external | ||
}) | ||
.then(function (bundle) { | ||
var dest = 'dist/' + (opts.output || opts.entry) | ||
|
||
console.log(dest) | ||
bundle.write({ | ||
format: opts.format || 'umd', | ||
moduleName: opts.moduleName || 'Vuep', | ||
globals: { | ||
codemirror: 'CodeMirror', | ||
'vue/dist/vue.common': 'Vue' | ||
}, | ||
dest: dest | ||
}) | ||
}) | ||
.catch(function (err) { | ||
console.error(err) | ||
}) | ||
} | ||
|
||
build({ | ||
entry: 'index.umd.js', | ||
output: 'vuep.js', | ||
external: ['vue/dist/vue.common'] | ||
}) | ||
|
||
build({ | ||
entry: 'index.umd.js', | ||
output: 'vuep.min.js', | ||
plugins: [uglify()], | ||
external: ['vue/dist/vue.common'] | ||
}) | ||
|
||
build({ | ||
entry: 'index.js', | ||
output: 'vuep.common.js', | ||
format: 'cjs', | ||
external: ['codemirror', 'vue/dist/vue.common'] | ||
}) |
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
Empty file.
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,116 @@ | ||
# Demo | ||
<vuep template="#demo1"></vuep> | ||
|
||
<script type="text/x-template" id="demo1"> | ||
<template> | ||
<div>Hello, {{ name }}!</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { name: 'Vue' } | ||
} | ||
} | ||
</script> | ||
</script> | ||
|
||
|
||
<br> | ||
# Usage | ||
|
||
## CommonJS | ||
**Need the full (compiler-included) CommonJS build of Vue** | ||
|
||
webpack config | ||
```javascript | ||
{ | ||
alias: { | ||
'vue$': 'vue/dist/vue.common' | ||
} | ||
} | ||
``` | ||
|
||
```javascript | ||
import Vue from 'vue' | ||
import Vuep from 'vuep' | ||
|
||
Vue.use(Vuep {, /* codemirror options */ }) | ||
// or Vue.component('Vuep', Vuep) | ||
|
||
new Vue({ | ||
el: '#app', | ||
|
||
created: function () { | ||
this.code = ` | ||
<template> | ||
<div>Hello, {{ name }}!</div> | ||
</template> | ||
<script> | ||
export default { | ||
data: function () { | ||
return { name: 'Vue' } | ||
} | ||
} | ||
</script> | ||
` | ||
} | ||
}) | ||
``` | ||
|
||
template | ||
```html | ||
<div id="app"> | ||
<vuep :template="code"></vuep> | ||
</div> | ||
``` | ||
|
||
## UMD | ||
|
||
index.html | ||
```html | ||
<!-- Import theme --> | ||
<link rel="stylesheet" href="//unpkg.com/vuep.css"> | ||
|
||
<!-- depend vue --> | ||
<script src="//unpkg.com/vue"></script> | ||
<script src="//unpkg.com/vuep"></script> | ||
``` | ||
|
||
template | ||
```html | ||
<vuep template="#example"></vuep> | ||
|
||
<script type="text/x-template" id="example"> | ||
<template> | ||
<div>Hello, {{ name }}!</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data: function () { | ||
return { name: 'Vue' } | ||
} | ||
} | ||
</script> | ||
</script> | ||
``` | ||
|
||
# Options | ||
|
||
https://codemirror.net/index.html | ||
|
||
```javascript | ||
Vue.use(Vuep, { /* codemirror config */ }) | ||
``` | ||
|
||
Default config | ||
```json | ||
{ | ||
"lineNumbers": true, | ||
"mode": "text/x-vue", | ||
"theme": "material", | ||
"tabSize": 2 | ||
} | ||
``` |
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,8 @@ | ||
|
||
# Vuep <small>0.1.0</small> | ||
|
||
> A component for rendering Vue components with live editor and preview. | ||
|
||
[GitHub](https://github.com/QingWei-Li/vuep/) | ||
[Get Started](#demo) |
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,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Vuep - A component for rendering Vue components with live editor and preview.</title> | ||
<meta name="description" content="A component for rendering Vue components with live editor and preview."> | ||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css"> | ||
<link rel="stylesheet" href="//unpkg.com/vuep/dist/vuep.css"> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
<script src="//unpkg.com/vue"></script> | ||
<script src="//unpkg.com/vuep/dist/vuep.min.js"></script> | ||
<script | ||
src="//unpkg.com/docsify/lib/docsify.min.js" | ||
data-sidebar-toggle | ||
data-coverpage | ||
data-router></script> | ||
</html> |
Oops, something went wrong.