From f1f8846b0adc6dd330286d2edeb399215530a391 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 2 Nov 2016 18:01:26 +0800 Subject: [PATCH] Config extra entry for html.min.css --- public/js/extra.js | 2 +- public/js/htmlExport.js | 5 +++++ webpack.config.js | 29 +++++++++++++++++++++++++++-- webpack.production.js | 33 +++++++++++++++++++++++++++++++-- 4 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 public/js/htmlExport.js diff --git a/public/js/extra.js b/public/js/extra.js index 0136388..81dd4a2 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -588,7 +588,7 @@ function exportToHTML(view) { var tocAffix = $('#ui-toc-affix').clone(); tocAffix.find('*').removeClass('active').find("a[href^='#'][smoothhashscroll]").removeAttr('smoothhashscroll'); //generate html via template - $.get(serverurl + '/css/html.min.css', function (css) { + $.get(serverurl + '/build/html.min.css', function (css) { $.get(serverurl + '/views/html.hbs', function (data) { var template = Handlebars.compile(data); var context = { diff --git a/public/js/htmlExport.js b/public/js/htmlExport.js new file mode 100644 index 0000000..e9fc41c --- /dev/null +++ b/public/js/htmlExport.js @@ -0,0 +1,5 @@ +require('../css/github-extract.css'); +require('../css/markdown.css'); +require('../css/extra.css'); +require('../css/slide-preview.css'); +require('../css/site.css'); diff --git a/webpack.config.js b/webpack.config.js index 6a436f4..f9d9a6d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,8 +1,33 @@ var baseConfig = require('./webpackBaseConfig'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); +var path = require('path'); -module.exports = Object.assign({}, baseConfig, { +module.exports = [Object.assign({}, baseConfig, { plugins: baseConfig.plugins.concat([ new ExtractTextPlugin("[name].css") ]) -}); +}), { + entry: { + htmlExport: path.join(__dirname, 'public/js/htmlExport.js') + }, + module: { + loaders: [{ + test: /\.css$/, + loader: ExtractTextPlugin.extract('style-loader', 'css-loader') + }, { + test: /\.scss$/, + loader: ExtractTextPlugin.extract('style-loader', 'sass-loader') + }, { + test: /\.less$/, + loader: ExtractTextPlugin.extract('style-loader', 'less-loader') + }] + }, + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[name].js' + }, + plugins: [ + new ExtractTextPlugin("html.min.[hash].css") + ] +}]; diff --git a/webpack.production.js b/webpack.production.js index 1a55e61..a4dfd24 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -3,7 +3,7 @@ var webpack = require('webpack'); var path = require('path'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); -module.exports = Object.assign({}, baseConfig, { +module.exports = [Object.assign({}, baseConfig, { plugins: baseConfig.plugins.concat([ new webpack.DefinePlugin({ 'process.env': { @@ -25,4 +25,33 @@ module.exports = Object.assign({}, baseConfig, { publicPath: '/build/', filename: '[id].[name].[hash].js' } -}); +}), { + entry: { + htmlExport: path.join(__dirname, 'public/js/htmlExport.js') + }, + module: { + loaders: [{ + test: /\.css$/, + loader: ExtractTextPlugin.extract('style-loader', 'css-loader') + }, { + test: /\.scss$/, + loader: ExtractTextPlugin.extract('style-loader', 'sass-loader') + }, { + test: /\.less$/, + loader: ExtractTextPlugin.extract('style-loader', 'less-loader') + }] + }, + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[name].js' + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }), + new ExtractTextPlugin("html.min.css") + ] +}];