add button

This commit is contained in:
niunai
2017-02-06 10:30:43 +08:00
parent 347dc1751c
commit 4562ca8b19
23 changed files with 616 additions and 117 deletions

View File

@@ -8,6 +8,14 @@ var OUTPUT_PATH = path.join(__dirname, '../../src/index.js');
var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';';
var ISNTALL_COMPONENT_TEMPLATE = ' Vue.component({{name}}.name, {{name}});';
var MAIN_TEMPLATE = `{{include}}
import 'es6-promise/auto';
import axios from 'axios';
import foreach from 'lodash/foreach';
import filter from 'lodash/filter';
import find from 'lodash/find';
import map from 'lodash/map';
// zenui
import '../packages/zenui/src/index.pcss';
const install = function(Vue) {
if (install.installed) return;
@@ -23,6 +31,13 @@ if (typeof window !== 'undefined' && window.Vue) {
module.exports = {
install,
version: '{{version}}',
axios,
_: {
foreach,
filter,
find,
map
},
{{list}}
};
`;

View File

@@ -0,0 +1,66 @@
/**
* Created by tsxuehu on 17/1/4.
*/
var config = {
"bem": {
"shortcuts": {"component": "c", "modifier": "m", "descendent": "d"},
"separators": {"descendent": "-", "modifier": "--"}
}/*,
"autoprefixer": {"browsers": ["ie > 8", "last 2 versions"]},
"rem": {"browsers": ["ie > 8", "last 2 versions"]}*/
};
// https://github.com/trysound/postcss-easy-import
var partialImport = require("postcss-easy-import");
// 这不是bem虽然名字叫bem其实它是suit
// https://github.com/saladcss/saladcss-bem
var bem = require("saladcss-bem")(config.bem);
// https://github.com/jonathantneal/precss
var precss = require("precss")();
// https://github.com/adam-h/postcss-sass-color-functions
var sassColor = require("postcss-sass-color-functions")();
// eleme的组件---
// https://npmjs.com/package/postcss-css-reset
// http://elemefe.github.io/postcss-salad/
var reset = require("postcss-css-reset")();
// eleme的组件---
// https://npmjs.com/package/postcss-utils
// http://elemefe.github.io/postcss-salad/
var utils = require("postcss-utils")();
// https://github.com/postcss/postcss-calc
var calc = require("postcss-calc")();
// https://github.com/maximkoretskiy/postcss-initial
var initial = require("postcss-initial")();
// https://github.com/trysound/postcss-inline-svg
var inlineSvg = require("postcss-inline-svg")();
// https://github.com/jonathantneal/postcss-short
var short = require("postcss-short")();
// eleme的组件---
// https://github.com/baiyaaaaa/postcss-shape
// http://elemefe.github.io/postcss-salad/
var shape = require("postcss-shape")();
// https://github.com/robwierzbowski/node-pixrem
var rem = require("pixrem")();
// https://github.com/postcss/autoprefixer
var autoprefixer = require("autoprefixer")();
// https://github.com/jo-asakura/postcss-neat
var neat = require("postcss-neat")();
module.exports = function (webpack) {
// 顺序很重要
return [partialImport({ addDependencyTo: webpack }), bem, precss, sassColor, reset,
utils, calc, initial, inlineSvg, short, shape, rem, autoprefixer, neat];
};

View File

@@ -1,8 +1,11 @@
var webpack = require('webpack')
var path = require('path')
var slugify = require('transliteration').slugify
var md = require('markdown-it')()
var striptags = require('./strip-tags')
var webpack = require('webpack');
var path = require('path');
var slugify = require('transliteration').slugify;
var md = require('markdown-it')();
var striptags = require('./strip-tags');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var version = require('../package.json').version;
var getPoastcssPlugin = require('./utils/postcss_pipe');
function convert(str) {
str = str.replace(/(&#x)(\w{4});/gi, function($0) {
@@ -29,108 +32,50 @@ module.exports = {
filename: '[name].js'
},
resolve: {
root: path.resolve('./'),
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')]
modules: [
path.join(__dirname, '../node_modules'),
'node_modules'
],
extensions: ['.js', '.vue', '.pcss'],
alias: {
'vue$': 'vue/dist/vue.runtime.common.js',
'oxygen': path.join(__dirname, '..'),
'src': path.join(__dirname, '../src')
}
},
module: {
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
loader: 'vue-loader'
},
{
test: /\.js$/,
exclude: /node_modules|vue\/src|vue-router\/|vue-loader\/|vue-hot-reload-api\//,
loader: 'babel'
loader: 'babel-loader'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader?root=./docs/'
},
{
test: /\.scss$/,
loader: 'style!css!sass'
test: /\.pcss$/,
loader: 'style-loader!css-loader!postcss-loader'
},
{
test: /\.less$/,
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'
loader: 'url-loader'
}
]
},
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'
};
@@ -146,6 +91,79 @@ if (process.env.NODE_ENV === 'production') {
compress: {
warnings: false
}
}),
new ExtractTextPlugin(`yzvue_base_${version}_min.css`),
new webpack.optimize.UglifyJsPlugin({
compress: {warnings: false},
output: {comments: false},
sourceMap: false
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
];
}
} else {
// development 环境不会抽css - -
module.exports.plugins = [
new ExtractTextPlugin('style.dev.css'),
new webpack.LoaderOptionsPlugin({
minimize: true,
options: {
postcss: getPoastcssPlugin,
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
vue: {
autoprefixer: false,
postcss: getPoastcssPlugin
},
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;
}
}
}
})
];
};