From 296372f194d150fda2b9cec8f6190c88bf701e31 Mon Sep 17 00:00:00 2001 From: infeng Date: Sat, 22 Oct 2016 10:31:26 +0800 Subject: [PATCH] add gh_pages build --- package.json | 3 ++- webpack.config.doc.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 webpack.config.doc.js diff --git a/package.json b/package.json index 358f489..729173a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "test": "echo \"Error: no test specified\" && exit 1", "start": "dora --port 8001 --plugins \"webpack,webpack-hmr,browser-history?index=/demo/index.html\"", "lint": "tslint -c tslint.json src/**/*.ts src/**/*.tsx", - "build": "atool-build --config webpack.config.prop.js && gulp" + "build": "atool-build --config webpack.config.prop.js && gulp", + "doc": "atool-build --config webpack.config.doc.js" }, "repository": { "type": "git", diff --git a/webpack.config.doc.js b/webpack.config.doc.js new file mode 100644 index 0000000..0873074 --- /dev/null +++ b/webpack.config.doc.js @@ -0,0 +1,42 @@ +const webpack = require('atool-build/lib/webpack'); +var HtmlWebpackPlugin = require('html-webpack-plugin'); + +var conf = { + filename: 'index.html', + template: './demo/index.html', + inject: true, + minify: { + removeComments: true, + collapseWhitespace: false + }, + hash: true, +} + +module.exports = function (webpackConfig) { + webpackConfig.entry = { + index: './demo/index.tsx', + }; + + webpackConfig.output.path = './docs'; + webpackConfig.output.publicPath = '/'; + + webpackConfig.module.loaders.forEach(function (loader, index) { + if (loader.test.toString().indexOf('html') > 0) { + loader.loader = 'html'; + } + }); + + webpackConfig.plugins.push( + new HtmlWebpackPlugin(conf) + ); + + webpackConfig.plugins.some(function (plugin, i) { + if (plugin instanceof webpack.optimize.CommonsChunkPlugin) { + webpackConfig.plugins.splice(i, 1); + + return true; + } + }); + + return webpackConfig; +}; \ No newline at end of file