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