Skip to content

Commit f72d460

Browse files
authored
Merge pull request sagalbot#422 from sagalbot/gitbook
Updated Homepage, GitBook Docs
2 parents 4095643 + af9d7f7 commit f72d460

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+7127
-2311
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ npm-debug.log
55
test/unit/coverage
66
.coveralls.yml
77
.flowconfig
8+
docs/gitbook/_book
9+
docs/node_modules
10+
site

book.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"title": "vue-select",
3+
"gitbook": ">3.0.0",
4+
"root": "./docs/gitbook",
5+
"plugins": ["edit-link", "-fontsettings", "codepen", "include-csv"],
6+
"pluginsConfig": {
7+
"edit-link": {
8+
"base": "https://github.com/sagalbot/vue-select/edit/gitbook/docs/gitbook",
9+
"label": "Edit This Page"
10+
},
11+
"github": {
12+
"url": "https://github.com/sagalbot/vue-select/"
13+
},
14+
"codepen": {
15+
"theme": 32252
16+
}
17+
},
18+
"links": {
19+
"sharing": {
20+
"facebook": false,
21+
"twitter": false
22+
}
23+
}
24+
}

build/build-docs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://github.com/shelljs/shelljs
2+
const shell = require('shelljs');
3+
4+
shell.exec('gitbook build', (code, stdout, stderr) => {
5+
if( code === 0 ) {
6+
shell.rm('-rf', 'site/docs');
7+
shell.exec('mv _book site/docs')
8+
}
9+
});

build/build.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
// https://github.com/shelljs/shelljs
2-
require('shelljs/global')
3-
env.NODE_ENV = 'production'
2+
require('shelljs/global');
3+
env.NODE_ENV = 'production';
44

5-
var path = require('path')
6-
var config = require('../config')
7-
var ora = require('ora')
8-
var webpack = require('webpack')
9-
var webpackConfig = require('./webpack.prod.conf')
5+
var path = require('path');
6+
var config = require('../config');
7+
var ora = require('ora');
8+
var webpack = require('webpack');
9+
var utils = require('./utils');
10+
var webpackConfig = utils.shouldBuildHomepage() ? require('./webpack.site.conf') : require('./webpack.prod.conf');
1011

11-
var spinner = ora('building UMD module...')
12-
spinner.start()
12+
var text = utils.shouldBuildHomepage() ? 'homepage' : 'vue-select UMD module';
13+
var spinner = ora(`building ${text}...`);
14+
spinner.start();
1315

14-
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
15-
rm('-rf', assetsPath)
16-
mkdir('-p', assetsPath)
16+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory);
17+
if (!utils.shouldBuildHomepage()) {
18+
rm('-rf', assetsPath);
19+
mkdir('-p', assetsPath);
20+
}
1721

1822
/**
1923
* Build the /dist/ folder
2024
*/
2125
webpack(webpackConfig, function (err, stats) {
22-
spinner.stop()
23-
if (err) throw err
24-
process.stdout.write(stats.toString({
25-
colors: true,
26-
modules: false,
27-
children: false,
28-
chunks: false,
29-
chunkModules: false
30-
}) + '\n')
31-
})
26+
spinner.stop();
27+
if (err) throw err;
28+
process.stdout.write(stats.toString({
29+
colors: true,
30+
modules: false,
31+
children: false,
32+
chunks: false,
33+
chunkModules: false
34+
}) + '\n')
35+
});

build/utils.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@ var path = require('path')
22
var config = require('../config')
33
var ExtractTextPlugin = require('extract-text-webpack-plugin')
44

5+
/**
6+
* Get the path to the assetsSubDirectory
7+
* @param _path
8+
* @returns {*|string}
9+
*/
510
exports.assetsPath = function (_path) {
611
return path.posix.join(config.build.assetsSubDirectory, _path)
712
}
813

14+
/**
15+
* Generate loader string to be used with extract text plugin
16+
* @param options
17+
* @returns {{css: *, postcss: *, less: *, sass: *, scss: *, stylus: *, styl: *}}
18+
*/
919
exports.cssLoaders = function (options) {
1020
options = options || {}
11-
// generate loader string to be used with extract text plugin
21+
1222
function generateLoaders (loaders) {
1323
var sourceLoader = loaders.map(function (loader) {
1424
var extraParamChar
@@ -41,7 +51,11 @@ exports.cssLoaders = function (options) {
4151
}
4252
}
4353

44-
// Generate loaders for standalone style files (outside of .vue)
54+
/**
55+
* Generate loaders for standalone style files (outside of .vue)
56+
* @param options
57+
* @returns {Array}
58+
*/
4559
exports.styleLoaders = function (options) {
4660
var output = []
4761
var loaders = exports.cssLoaders(options)
@@ -54,3 +68,16 @@ exports.styleLoaders = function (options) {
5468
}
5569
return output
5670
}
71+
72+
/**
73+
* Are we serving the docs or
74+
* the dev environment?
75+
* @returns {boolean}
76+
*/
77+
exports.shouldServeHomepage = function () {
78+
return process.argv.indexOf('--docs') > 0
79+
}
80+
81+
exports.shouldBuildHomepage = function () {
82+
return process.argv.indexOf('--homepage') > 0
83+
}

build/webpack.base.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var projectRoot = path.resolve(__dirname, '../')
55

66
module.exports = {
77
entry: {
8-
app: process.argv.indexOf('--docs') > 0 ? './docs/docs.js' : './src/dev.js',
8+
app: utils.shouldServeHomepage() ? './docs/homepage/home.js' : './src/dev.js',
99
},
1010
output: {
1111
path: config.build.assetsRoot,

build/webpack.dev.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = merge(baseWebpackConfig, {
2727
// https://github.com/ampedandwired/html-webpack-plugin
2828
new HtmlWebpackPlugin({
2929
filename: 'index.html',
30-
template: process.argv.indexOf('--docs') > 0 ? './docs/docs.html' : 'dev.html',
30+
template: utils.shouldServeHomepage() ? './docs/homepage/home.html' : 'dev.html',
3131
inject: true
3232
})
3333
],

build/webpack.site.conf.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var utils = require('./utils')
4+
var webpack = require('webpack')
5+
var merge = require('webpack-merge')
6+
var baseWebpackConfig = require('./webpack.base.conf')
7+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
8+
var HtmlWebpackPlugin = require('html-webpack-plugin')
9+
var env = process.env.NODE_ENV === 'testing'
10+
? require('../config/test.env')
11+
: config.homepage.env
12+
13+
module.exports = merge(baseWebpackConfig, {
14+
entry: {
15+
app: config.homepage.entry
16+
},
17+
module: {
18+
loaders: utils.styleLoaders({ sourceMap: config.homepage.productionSourceMap, extract: true })
19+
},
20+
devtool: config.homepage.productionSourceMap ? '#source-map' : false,
21+
output: {
22+
publicPath: config.homepage.assetsPublicPath,
23+
path: config.homepage.assetsRoot,
24+
filename: utils.assetsPath('js/[name].[chunkhash].js'),
25+
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
26+
},
27+
vue: {
28+
loaders: utils.cssLoaders({
29+
sourceMap: config.homepage.productionSourceMap,
30+
extract: true
31+
})
32+
},
33+
plugins: [
34+
// http://vuejs.github.io/vue-loader/workflow/production.html
35+
new webpack.DefinePlugin({
36+
'process.env': env
37+
}),
38+
new webpack.optimize.UglifyJsPlugin({
39+
compress: {
40+
warnings: false
41+
}
42+
}),
43+
new webpack.optimize.OccurenceOrderPlugin(),
44+
// extract css into its own file
45+
new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
46+
// generate dist index.html with correct asset hash for caching.
47+
// you can customize output by editing /index.html
48+
// see https://github.com/ampedandwired/html-webpack-plugin
49+
new HtmlWebpackPlugin({
50+
filename: 'index.html',
51+
template: './docs/homepage/home.html',
52+
inject: true,
53+
minify: {
54+
removeComments: true,
55+
collapseWhitespace: true,
56+
removeAttributeQuotes: true
57+
// more options:
58+
// https://github.com/kangax/html-minifier#options-quick-reference
59+
},
60+
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
61+
chunksSortMode: 'dependency'
62+
}),
63+
// split vendor js into its own file
64+
new webpack.optimize.CommonsChunkPlugin({
65+
name: 'vendor',
66+
minChunks: function (module, count) {
67+
// any required modules inside node_modules are extracted to vendor
68+
return (
69+
module.resource &&
70+
module.resource.indexOf(
71+
path.join(__dirname, '../node_modules')
72+
) === 0
73+
)
74+
}
75+
}),
76+
// extract webpack runtime and module manifest to its own file in order to
77+
// prevent vendor hash from being updated whenever app bundle is updated
78+
new webpack.optimize.CommonsChunkPlugin({
79+
name: 'manifest',
80+
chunks: ['vendor']
81+
})
82+
]
83+
})

config/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// see http://vuejs-templates.github.io/webpack for documentation.
2-
var path = require('path')
2+
var path = require('path');
33

44
module.exports = {
55
build: {
@@ -17,5 +17,14 @@ module.exports = {
1717
umd: {
1818
assetsRoot: path.resolve(__dirname, '../umd'),
1919
assetsPublicPath: '/'
20+
},
21+
homepage: {
22+
env: require('./prod.env'),
23+
entry: './docs/homepage/home.js',
24+
assetsRoot: path.resolve(__dirname, '../site'),
25+
assetsSubDirectory: '',
26+
assetsPublicPath: '',
27+
productionSourceMap: true
2028
}
21-
}
29+
};
30+

docs/Docs.vue

Lines changed: 0 additions & 54 deletions
This file was deleted.

docs/assets/fonts/octicons.eot

-30.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)