mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
update build process for docs
This commit is contained in:
+2
-1
@@ -6,4 +6,5 @@ test/unit/coverage
|
|||||||
.coveralls.yml
|
.coveralls.yml
|
||||||
.flowconfig
|
.flowconfig
|
||||||
docs/gitbook/_book
|
docs/gitbook/_book
|
||||||
docs/node_modules
|
docs/node_modules
|
||||||
|
site
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// https://github.com/shelljs/shelljs
|
||||||
|
const shell = require('shelljs');
|
||||||
|
|
||||||
|
shell.exec('gitbook build', (code, stdout, stderr) => {
|
||||||
|
if( code === 0 ) {
|
||||||
|
shell.exec('mv _book site/docs')
|
||||||
|
}
|
||||||
|
});
|
||||||
+24
-22
@@ -1,31 +1,33 @@
|
|||||||
// https://github.com/shelljs/shelljs
|
// https://github.com/shelljs/shelljs
|
||||||
require('shelljs/global')
|
require('shelljs/global');
|
||||||
env.NODE_ENV = 'production'
|
env.NODE_ENV = 'production';
|
||||||
|
|
||||||
var path = require('path')
|
var path = require('path');
|
||||||
var config = require('../config')
|
var config = require('../config');
|
||||||
var ora = require('ora')
|
var ora = require('ora');
|
||||||
var webpack = require('webpack')
|
var webpack = require('webpack');
|
||||||
var webpackConfig = require('./webpack.prod.conf')
|
var utils = require('./utils');
|
||||||
|
var webpackConfig = utils.shouldBuildHomepage() ? require('./webpack.site.conf') : require('./webpack.prod.conf');
|
||||||
|
|
||||||
var spinner = ora('building UMD module...')
|
var text = utils.shouldBuildHomepage() ? 'homepage' : 'vue-select UMD module';
|
||||||
spinner.start()
|
var spinner = ora(`building ${text}...`);
|
||||||
|
spinner.start();
|
||||||
|
|
||||||
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
|
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory);
|
||||||
rm('-rf', assetsPath)
|
rm('-rf', assetsPath);
|
||||||
mkdir('-p', assetsPath)
|
mkdir('-p', assetsPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the /dist/ folder
|
* Build the /dist/ folder
|
||||||
*/
|
*/
|
||||||
webpack(webpackConfig, function (err, stats) {
|
webpack(webpackConfig, function (err, stats) {
|
||||||
spinner.stop()
|
spinner.stop();
|
||||||
if (err) throw err
|
if (err) throw err;
|
||||||
process.stdout.write(stats.toString({
|
process.stdout.write(stats.toString({
|
||||||
colors: true,
|
colors: true,
|
||||||
modules: false,
|
modules: false,
|
||||||
children: false,
|
children: false,
|
||||||
chunks: false,
|
chunks: false,
|
||||||
chunkModules: false
|
chunkModules: false
|
||||||
}) + '\n')
|
}) + '\n')
|
||||||
})
|
});
|
||||||
@@ -76,4 +76,8 @@ exports.styleLoaders = function (options) {
|
|||||||
*/
|
*/
|
||||||
exports.shouldServeHomepage = function () {
|
exports.shouldServeHomepage = function () {
|
||||||
return process.argv.indexOf('--docs') > 0
|
return process.argv.indexOf('--docs') > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.shouldBuildHomepage = function () {
|
||||||
|
return process.argv.indexOf('--homepage') > 0
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
var path = require('path')
|
||||||
|
var config = require('../config')
|
||||||
|
var utils = require('./utils')
|
||||||
|
var webpack = require('webpack')
|
||||||
|
var merge = require('webpack-merge')
|
||||||
|
var baseWebpackConfig = require('./webpack.base.conf')
|
||||||
|
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
|
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
|
var env = process.env.NODE_ENV === 'testing'
|
||||||
|
? require('../config/test.env')
|
||||||
|
: config.homepage.env
|
||||||
|
|
||||||
|
module.exports = merge(baseWebpackConfig, {
|
||||||
|
entry: {
|
||||||
|
app: config.homepage.entry
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
loaders: utils.styleLoaders({ sourceMap: config.homepage.productionSourceMap, extract: true })
|
||||||
|
},
|
||||||
|
devtool: config.homepage.productionSourceMap ? '#source-map' : false,
|
||||||
|
output: {
|
||||||
|
path: config.homepage.assetsRoot,
|
||||||
|
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
||||||
|
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
||||||
|
},
|
||||||
|
vue: {
|
||||||
|
loaders: utils.cssLoaders({
|
||||||
|
sourceMap: config.homepage.productionSourceMap,
|
||||||
|
extract: true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// http://vuejs.github.io/vue-loader/workflow/production.html
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': env
|
||||||
|
}),
|
||||||
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
|
compress: {
|
||||||
|
warnings: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
new webpack.optimize.OccurenceOrderPlugin(),
|
||||||
|
// extract css into its own file
|
||||||
|
new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
|
||||||
|
// generate dist index.html with correct asset hash for caching.
|
||||||
|
// you can customize output by editing /index.html
|
||||||
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
filename: 'index.html',
|
||||||
|
template: './docs/homepage/home.html',
|
||||||
|
inject: true,
|
||||||
|
minify: {
|
||||||
|
removeComments: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
removeAttributeQuotes: true
|
||||||
|
// more options:
|
||||||
|
// https://github.com/kangax/html-minifier#options-quick-reference
|
||||||
|
},
|
||||||
|
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
||||||
|
chunksSortMode: 'dependency'
|
||||||
|
}),
|
||||||
|
// split vendor js into its own file
|
||||||
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
|
name: 'vendor',
|
||||||
|
minChunks: function (module, count) {
|
||||||
|
// any required modules inside node_modules are extracted to vendor
|
||||||
|
return (
|
||||||
|
module.resource &&
|
||||||
|
module.resource.indexOf(
|
||||||
|
path.join(__dirname, '../node_modules')
|
||||||
|
) === 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// extract webpack runtime and module manifest to its own file in order to
|
||||||
|
// prevent vendor hash from being updated whenever app bundle is updated
|
||||||
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
|
name: 'manifest',
|
||||||
|
chunks: ['vendor']
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
+11
-2
@@ -1,5 +1,5 @@
|
|||||||
// see http://vuejs-templates.github.io/webpack for documentation.
|
// see http://vuejs-templates.github.io/webpack for documentation.
|
||||||
var path = require('path')
|
var path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
build: {
|
build: {
|
||||||
@@ -17,5 +17,14 @@ module.exports = {
|
|||||||
umd: {
|
umd: {
|
||||||
assetsRoot: path.resolve(__dirname, '../umd'),
|
assetsRoot: path.resolve(__dirname, '../umd'),
|
||||||
assetsPublicPath: '/'
|
assetsPublicPath: '/'
|
||||||
|
},
|
||||||
|
homepage: {
|
||||||
|
env: require('./prod.env'),
|
||||||
|
entry: './docs/homepage/home.js',
|
||||||
|
assetsRoot: path.resolve(__dirname, '../site'),
|
||||||
|
assetsSubDirectory: '',
|
||||||
|
assetsPublicPath: '/',
|
||||||
|
productionSourceMap: true
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
"dev:docs": "gitbook serve",
|
"dev:docs": "gitbook serve",
|
||||||
"build": "node build/build.js",
|
"build": "node build/build.js",
|
||||||
"build:homepage": "node build/build.js --homepage",
|
"build:homepage": "node build/build.js --homepage",
|
||||||
"build:docs": "gitbook build",
|
"build:docs": "yarn run build:homepage && node build/build-docs.js",
|
||||||
"lint": "eslint --ext .js,.vue src test/unit/specs",
|
"lint": "eslint --ext .js,.vue src test/unit/specs",
|
||||||
"test": "karma start test/unit/karma.conf.js --single-run",
|
"test": "karma start test/unit/karma.conf.js --single-run",
|
||||||
"test-watch": "karma start test/unit/karma.conf.js --single-run=false --auto-watch=true"
|
"test-watch": "karma start test/unit/karma.conf.js --single-run=false --auto-watch=true"
|
||||||
|
|||||||
Reference in New Issue
Block a user