添加doc预览
This commit is contained in:
@@ -13,7 +13,6 @@ const install = function(Vue) {
|
||||
if (install.installed) return;
|
||||
|
||||
{{install}}
|
||||
|
||||
};
|
||||
|
||||
// auto install
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
var Components = require('../components.json');
|
||||
var path = require('path');
|
||||
var dependencies = require('../package.json').dependencies;
|
||||
var externals = {};
|
||||
|
||||
Object.keys(Components).forEach(function(key) {
|
||||
externals[`oxygen/packages/${key}/index.js`] = `oxygen/lib/${key}`;
|
||||
externals[`oxygen/packages/${key}/style.css`] = `oxygen/lib/${key}/style.css`;
|
||||
});
|
||||
Object.keys(dependencies).forEach(function(key) {
|
||||
externals[key] = key;
|
||||
});
|
||||
exports.externals = Object.assign({
|
||||
vue: {
|
||||
root: 'Vue',
|
||||
commonjs: 'vue',
|
||||
commonjs2: 'vue',
|
||||
amd: 'vue'
|
||||
}
|
||||
}, externals);
|
||||
|
||||
exports.alias = {
|
||||
'oxygen': path.join(__dirname, '..'),
|
||||
'src': path.join(__dirname, '../src')
|
||||
};
|
||||
|
||||
exports.jsexclude = /node_modules|lib/;
|
||||
|
||||
exports.extends = ['vue2', 'buble'];
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
set -e
|
||||
echo "[Mint UI for Vue 2.0]Enter release version: "
|
||||
read VERSION
|
||||
|
||||
read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r
|
||||
echo # (optional) move to a new line
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
echo "Releasing $VERSION ..."
|
||||
|
||||
# build
|
||||
VERSION=$VERSION npm run dist
|
||||
|
||||
# commit
|
||||
git add -A
|
||||
git commit -m "[build] $VERSION"
|
||||
npm version $VERSION --message "[release] $VERSION"
|
||||
|
||||
# publish
|
||||
git push eleme refs/tags/v$VERSION
|
||||
git push eleme master
|
||||
npm publish
|
||||
fi
|
||||
@@ -0,0 +1,34 @@
|
||||
/*!
|
||||
* strip-tags <https://github.com/jonschlinkert/strip-tags>
|
||||
*
|
||||
* Copyright (c) 2015 Jon Schlinkert, contributors.
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var cheerio = require('cheerio');
|
||||
|
||||
exports.strip = function(str, tags) {
|
||||
var $ = cheerio.load(str, {decodeEntities: false});
|
||||
|
||||
if (!tags || tags.length === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
tags = !Array.isArray(tags) ? [tags] : tags;
|
||||
var len = tags.length;
|
||||
|
||||
while (len--) {
|
||||
$(tags[len]).remove();
|
||||
}
|
||||
|
||||
return $.html();
|
||||
};
|
||||
|
||||
exports.fetch = function(str, tag) {
|
||||
var $ = cheerio.load(str, {decodeEntities: false});
|
||||
if (!tag) return str;
|
||||
|
||||
return $(tag).html();
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
var config = require('./webpack.config.js')
|
||||
|
||||
config.entry = {
|
||||
'oxygen': './src/index.js'
|
||||
}
|
||||
|
||||
config.output = {
|
||||
filename: './dist/[name].js',
|
||||
library: 'Oxygen',
|
||||
libraryTarget: 'umd'
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
var config = require('./webpack.build.js')
|
||||
var webpack = require('webpack')
|
||||
|
||||
|
||||
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
|
||||
|
||||
delete config.devtool
|
||||
|
||||
config.plugins = [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
sourceMap: false,
|
||||
drop_console: true,
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
module.exports = config
|
||||
@@ -0,0 +1,151 @@
|
||||
var webpack = require('webpack')
|
||||
var path = require('path')
|
||||
var slugify = require('transliteration').slugify
|
||||
var md = require('markdown-it')()
|
||||
var striptags = require('./strip-tags')
|
||||
|
||||
function convert(str) {
|
||||
str = str.replace(/(&#x)(\w{4});/gi, function($0) {
|
||||
return String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16));
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
function wrap(render) {
|
||||
return function() {
|
||||
return render.apply(this, arguments)
|
||||
.replace('<code class="', '<code class="hljs ')
|
||||
.replace('<code>', '<code class="hljs">');
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
'build-docs': './docs/index.js'
|
||||
},
|
||||
output: {
|
||||
path: './docs/build',
|
||||
publicPath: 'docs/build',
|
||||
filename: '[name].js'
|
||||
},
|
||||
resolve: {
|
||||
root: path.resolve('./'),
|
||||
extensions: ['', '.js', '.vue'],
|
||||
fallback: [path.join(__dirname, '../node_modules')]
|
||||
},
|
||||
module: {
|
||||
preLoaders: [
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'eslint',
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'eslint',
|
||||
exclude: /node_modules/
|
||||
}
|
||||
],
|
||||
loaders: [
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue'
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules|vue\/src|vue-router\/|vue-loader\/|vue-hot-reload-api\//,
|
||||
loader: 'babel'
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
loader: 'style-loader!css-loader?root=./docs/'
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
loader: 'style!css!sass'
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
loader: 'style-loader!css-loader!less-loader'
|
||||
},
|
||||
{
|
||||
test: /\.md/,
|
||||
loader: 'vue-markdown-loader'
|
||||
},
|
||||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json'
|
||||
},
|
||||
{
|
||||
test: /\.(woff2?|eot|ttf|otf|svg)(\?.*)?$/,
|
||||
loader: 'url'
|
||||
}
|
||||
]
|
||||
},
|
||||
babel: {
|
||||
presets: ['es2015'],
|
||||
plugins: ['transform-runtime']
|
||||
},
|
||||
eslint: {
|
||||
formatter: require('eslint-friendly-formatter')
|
||||
},
|
||||
vueMarkdown: {
|
||||
use: [
|
||||
[require('markdown-it-anchor'), {
|
||||
level: 2,
|
||||
slugify: slugify,
|
||||
permalink: true,
|
||||
permalinkBefore: true
|
||||
}],
|
||||
[require('markdown-it-container'), 'demo', {
|
||||
validate: function(params) {
|
||||
return params.trim().match(/^demo\s*(.*)$/);
|
||||
},
|
||||
|
||||
render: function(tokens, idx) {
|
||||
var m = tokens[idx].info.trim().match(/^demo\s*(.*)$/);
|
||||
if (tokens[idx].nesting === 1) {
|
||||
var description = (m && m.length > 1) ? m[1] : '';
|
||||
var content = tokens[idx + 1].content;
|
||||
var html = convert(striptags.strip(content, ['script', 'style']));
|
||||
var script = striptags.fetch(content, 'script');
|
||||
var style = striptags.fetch(content, 'style');
|
||||
var descriptionHTML = description
|
||||
? md.render(description)
|
||||
: '';
|
||||
|
||||
return `<demo-block class="demo-box">
|
||||
<div class="source" slot="source">${html}</div>
|
||||
${descriptionHTML}
|
||||
<div class="highlight" slot="highlight">`;
|
||||
}
|
||||
return '</div></demo-block>\n';
|
||||
}
|
||||
}]
|
||||
],
|
||||
preprocess: function(MarkdownIt, source) {
|
||||
MarkdownIt.renderer.rules.table_open = function() {
|
||||
return '<table class="table">';
|
||||
};
|
||||
MarkdownIt.renderer.rules.fence = wrap(MarkdownIt.renderer.rules.fence);
|
||||
return source;
|
||||
}
|
||||
},
|
||||
devtool: 'source-map'
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
delete module.exports.devtool;
|
||||
module.exports.plugins = [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
NODE_ENV: '"production"'
|
||||
}
|
||||
}),
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
})
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user