Skip to content

Commit 040b9ac

Browse files
author
savoygu
committed
Initial commit
0 parents  commit 040b9ac

24 files changed

+1581
-0
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
["env", { "modules": false }]
4+
]
5+
}

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/*.js linguist-language=Vue
2+
**/*.less linguist-language=Vue
3+
**/*.css linguist-language=Vue
4+
**/*.html linguist-language=Vue

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
node_modules
3+
.idea
4+
example/dist
5+
gh-pages

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# vue-demonstration
2+
3+
> Vue-based element docs's demo code style component, asily add examples to your vue project to show your code.
4+
5+
## Build Setup
6+
7+
``` bash
8+
# install dependencies
9+
npm install
10+
11+
# serve with hot reload at localhost:8080
12+
npm run demo:dev
13+
14+
# build for demo with minification
15+
npm run demo:build
16+
17+
# build for gh-pages with minification
18+
npm run demo:prepublish
19+
20+
# build for production with minification
21+
npm run build
22+
```

build/gh-pages.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
npm run demo:prepublish
3+
cd gh-pages
4+
git init
5+
git add -A
6+
git commit -m 'update gh-pages'
7+
git push -f [email protected]:savoygu/vue-demonstration.git master:gh-pages

build/webpack.config.js

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
var path = require('path')
2+
var webpack = require('webpack')
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
4+
5+
module.exports = {
6+
entry: './src/index.js',
7+
output: {
8+
path: path.resolve(__dirname, '..', './lib'),
9+
filename: 'vue-demonstration.js',
10+
library: 'vue-demonstration',
11+
libraryTarget: 'umd'
12+
},
13+
externals: {
14+
vue: {
15+
root: 'Vue',
16+
commonjs: 'vue',
17+
commonjs2: 'vue',
18+
amd: 'vue'
19+
}
20+
},
21+
module: {
22+
rules: [
23+
{
24+
test: /\.vue$/,
25+
loader: 'vue-loader',
26+
options: {
27+
loaders: {
28+
css: 'vue-style-loader!css-loader',
29+
less: 'vue-style-loader!css-loader!less-loader',
30+
// css: ExtractTextPlugin.extract({
31+
// use: 'css-loader',
32+
// fallback: 'vue-style-loader'
33+
// }),
34+
// less: ExtractTextPlugin.extract({
35+
// fallback: 'vue-style-loader',
36+
// use: ['css-loader', 'less-loader']
37+
// })
38+
}
39+
// other vue-loader options go here
40+
}
41+
},
42+
{
43+
test: /\.css$/,
44+
use: [
45+
{ loader: 'css-loader' },
46+
{ loader: 'style-loader' }
47+
]
48+
// loader: ExtractTextPlugin.extract({
49+
// use: "css-loader",
50+
// fallback: "style-loader"
51+
// })
52+
},
53+
{
54+
test: /\.less$/,
55+
use: [
56+
{ loader: 'css-loader' },
57+
{ loader: 'style-loader' },
58+
{ loader: 'less-loader' }
59+
]
60+
// loader: ExtractTextPlugin.extract({
61+
// fallback: 'style-loader',
62+
// use: ['css-loader', 'less-loader']
63+
// })
64+
},
65+
{
66+
test: /\.js$/,
67+
loader: 'babel-loader',
68+
exclude: /node_modules/
69+
},
70+
{
71+
test: /\.(png|jpg|gif|svg)$/,
72+
loader: 'file-loader',
73+
options: {
74+
name: '[name].[ext]?[hash]'
75+
}
76+
},
77+
{
78+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
79+
loader: 'url-loader',
80+
query: {
81+
limit: 10000,
82+
name: path.posix.join('static', 'fonts/[name].[hash:7].[ext]')
83+
}
84+
}
85+
]
86+
},
87+
resolve: {
88+
extensions: ['.js', '.vue', '.json']
89+
},
90+
plugins: [
91+
new webpack.optimize.UglifyJsPlugin({
92+
sourceMap: true,
93+
compress: {
94+
warnings: false
95+
}
96+
})
97+
// ,
98+
// new ExtractTextPlugin({
99+
// filename: '../lib/vue-demonstration.css',
100+
// allChunks: true
101+
// })
102+
]
103+
}

build/webpack.example.base.conf.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
var path = require('path')
2+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
3+
var isProduction = process.env.NODE_ENV === 'production'
4+
5+
module.exports = {
6+
entry: {
7+
app: './example/src/main.js'
8+
},
9+
output: {
10+
path: '/example',
11+
filename: '[name].js',
12+
publicPath: '/'
13+
},
14+
module: {
15+
rules: [
16+
{
17+
test: /\.vue$/,
18+
loader: 'vue-loader',
19+
options: {
20+
// other vue-loader options go here
21+
loaders: {
22+
css: isProduction ? ExtractTextPlugin.extract({
23+
fallback: 'vue-style-loader',
24+
use: 'css-loader'
25+
}) : 'vue-style-loader!css-loader',
26+
less: isProduction ? ExtractTextPlugin.extract({
27+
fallback: 'vue-style-loader',
28+
use: ['css-loader', 'less-loader']
29+
}) : 'vue-style-loader!css-loader!less-loader'
30+
}
31+
}
32+
},
33+
{
34+
test: /\.js$/,
35+
loader: 'babel-loader',
36+
exclude: /node_modules/
37+
},
38+
{
39+
test: /\.(png|jpg|gif|svg)$/,
40+
loader: 'file-loader',
41+
options: {
42+
name: '[name].[ext]?[hash]'
43+
}
44+
},
45+
{
46+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
47+
loader: 'url-loader',
48+
query: {
49+
limit: 10000,
50+
name: path.posix.join('static', 'fonts/[name].[hash:7].[ext]')
51+
}
52+
}
53+
]
54+
}
55+
}

build/webpack.example.dev.conf.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var webpack = require('webpack')
2+
var merge = require('webpack-merge')
3+
var baseWebpackConfig = require('./webpack.example.base.conf')
4+
var HtmlWebpackPlugin = require('html-webpack-plugin')
5+
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
6+
7+
module.exports = merge(baseWebpackConfig, {
8+
module: {
9+
rules: [
10+
{
11+
test: /\.css$/,
12+
loader: 'vue-style-loader!css-loader'
13+
},
14+
{
15+
test: /\.less$/,
16+
loader: 'vue-style-loader!css-loader!less-loader'
17+
}
18+
]
19+
},
20+
// cheap-module-eval-source-map is faster for development
21+
devtool: '#cheap-module-eval-source-map',
22+
plugins: [
23+
new webpack.DefinePlugin({
24+
'process.env': {
25+
NODE_ENV: '"development"'
26+
}
27+
}),
28+
new webpack.NoEmitOnErrorsPlugin(),
29+
new HtmlWebpackPlugin({
30+
filename: 'index.html',
31+
template: 'example/index.html',
32+
inject: true
33+
}),
34+
new FriendlyErrorsPlugin()
35+
]
36+
})

build/webpack.example.prod.conf.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
var path = require('path')
2+
var webpack = require('webpack')
3+
var merge = require('webpack-merge')
4+
var baseWebpackConfig = require('./webpack.example.base.conf')
5+
var HtmlWebpackPlugin = require('html-webpack-plugin')
6+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
7+
var isProduction = process.env.NODE_ENV === 'production'
8+
9+
module.exports = merge(baseWebpackConfig, {
10+
module: {
11+
rules: [
12+
{
13+
test: /\.css$/,
14+
loader: ExtractTextPlugin.extract({
15+
fallback: "vue-style-loader",
16+
use: "css-loader"
17+
})
18+
},
19+
{
20+
test: /\.less/,
21+
loader: ExtractTextPlugin.extract({
22+
fallback: "vue-style-loader",
23+
use: ["css-loader", "less-loader"]
24+
})
25+
}
26+
]
27+
},
28+
devtool: '#source-map',
29+
output: {
30+
path: path.resolve(__dirname, '..', `${isProduction ? './example/dist' : 'gh-pages'}`),
31+
publicPath: isProduction ? '/' : '/vue-demonstration',
32+
filename: 'js/[name].[chunkhash].js'
33+
},
34+
plugins: [
35+
new webpack.DefinePlugin({
36+
'process.env': {
37+
NODE_ENV: '"production"'
38+
}
39+
}),
40+
new webpack.optimize.UglifyJsPlugin({
41+
sourceMap: true,
42+
compress: {
43+
warnings: false
44+
}
45+
}),
46+
new ExtractTextPlugin({
47+
filename: 'css/[name].[contenthash].css',
48+
allChunks: true
49+
}),
50+
new HtmlWebpackPlugin({
51+
filename: 'index.html',
52+
template: 'example/index.html',
53+
inject: true,
54+
minify: {
55+
removeComments: true,
56+
collapseWhitespace: true,
57+
removeAttributeQuotes: true
58+
// more options:
59+
// https://github.com/kangax/html-minifier#options-quick-reference
60+
},
61+
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
62+
chunksSortMode: 'dependency'
63+
})
64+
]
65+
})

example/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!Doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport"
6+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>vue-demonstration</title>
9+
</head>
10+
<body>
11+
<div id="app"></div>
12+
<!-- built files will be auto injected -->
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)