From 03772fe887716dad19b61d91e0e57f4f3c5afe91 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 19 Oct 2016 22:41:20 +0800 Subject: Refactor webpack production config --- webpack.production.js | 74 +++------------------------------------------------ 1 file changed, 3 insertions(+), 71 deletions(-) diff --git a/webpack.production.js b/webpack.production.js index 82e52d17..5fe6f294 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -1,77 +1,9 @@ var baseConfig = require('./webpackBaseConfig'); var webpack = require('webpack'); -var ExtractTextPlugin = require("extract-text-webpack-plugin"); var path = require('path'); -var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = Object.assign({}, baseConfig, { - plugins: [ - new webpack.ProvidePlugin({ - Visibility: "visibilityjs", - Cookies: "js-cookie", - key: "keymaster", - $: "jquery", - jQuery: "jquery", - "window.jQuery": "jquery", - "moment": "moment", - "Handlebars": "handlebars" - }), - new ExtractTextPlugin("[name].css"), - new webpack.optimize.CommonsChunkPlugin({ - names: ["cover", "index", "pretty", "slide", "vendor"], - children: true, - async: true, - filename: '[name].js', - minChunks: Infinity - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'index'], - filename: path.join(__dirname, 'public/views/build/index-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'index'], - filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'cover'], - filename: path.join(__dirname, 'public/views/build/cover-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'cover'], - filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'pretty'], - filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'pretty'], - filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'slide'], - filename: path.join(__dirname, 'public/views/build/slide-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'slide'], - filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'), - inject: false - }), + plugins: baseConfig.plugins.concat([ new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') @@ -84,11 +16,11 @@ module.exports = Object.assign({}, baseConfig, { mangle: false, sourceMap: false }) - ], + ]), output: { path: path.join(__dirname, 'public/build'), publicPath: '/build/', filename: '[id].[name].[hash].js' - }, + } }); -- cgit v1.2.3 From cd5977cd5f39ffbe4d1ab5afac0dd895a6b0f6ee Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Mon, 24 Oct 2016 19:28:01 +0800 Subject: Update editorconfig --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.editorconfig b/.editorconfig index e8019ba7..619c178d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,3 +9,7 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false + +[{.travis.yml,npm-shrinkwrap.json,package.json}] +indent_style = space +indent_size = 2 -- cgit v1.2.3 From 971bfe29f8a4e1004f039b21fb4bbc3972fd8a16 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 2 Nov 2016 11:25:21 +0800 Subject: Config webpack css hash in production --- webpack.config.js | 7 ++++++- webpack.production.js | 4 +++- webpackBaseConfig.js | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index d2cf3dc7..6a436f43 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,3 +1,8 @@ var baseConfig = require('./webpackBaseConfig'); +var ExtractTextPlugin = require("extract-text-webpack-plugin"); -module.exports = baseConfig; +module.exports = Object.assign({}, baseConfig, { + plugins: baseConfig.plugins.concat([ + new ExtractTextPlugin("[name].css") + ]) +}); diff --git a/webpack.production.js b/webpack.production.js index 5fe6f294..1a55e615 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -1,6 +1,7 @@ var baseConfig = require('./webpackBaseConfig'); var webpack = require('webpack'); var path = require('path'); +var ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = Object.assign({}, baseConfig, { plugins: baseConfig.plugins.concat([ @@ -15,7 +16,8 @@ module.exports = Object.assign({}, baseConfig, { }, mangle: false, sourceMap: false - }) + }), + new ExtractTextPlugin("[name].[hash].css") ]), output: { diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 4cc943dc..560635ca 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -15,7 +15,6 @@ module.exports = { "moment": "moment", "Handlebars": "handlebars" }), - new ExtractTextPlugin("[name].css"), new webpack.optimize.CommonsChunkPlugin({ names: ["cover", "index", "pretty", "slide", "vendor"], children: true, -- cgit v1.2.3 From 7a052b0dadae051c9ebec50c22d618e17585fa48 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 2 Nov 2016 11:26:06 +0800 Subject: Require index stylesheets --- public/js/index.js | 7 ++++++- public/views/head.ejs | 6 ++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index 8080b9c7..183a81c8 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,6 +1,11 @@ /* jquery and jquery plugins */ require('../vendor/showup/showup'); +require('../css/index.css'); +require('../css/extra.css'); +require('../css/slide-preview.css'); +require('../css/site.css'); + var toMarkdown = require('to-markdown'); var saveAs = require('file-saver').saveAs; @@ -2306,7 +2311,7 @@ socket.on('delete', function () { saveHistory(newnotehistory); location.href = serverurl; }); - } + } }); var retryTimer = null; socket.on('maintenance', function () { diff --git a/public/views/head.ejs b/public/views/head.ejs index 00571186..77cc1cf0 100644 --- a/public/views/head.ejs +++ b/public/views/head.ejs @@ -35,11 +35,9 @@ + <%- include build/index-header %> - - - - + <%- include build/cover-header %> - -
-- cgit v1.2.3 From 58fedb01faf8175d8454ff7edcb531cf36cef5c4 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 2 Nov 2016 11:55:08 +0800 Subject: Require pretty stylesheets --- public/js/pretty.js | 4 ++++ public/views/pretty.ejs | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/js/pretty.js b/public/js/pretty.js index 59403586..f7d31902 100644 --- a/public/js/pretty.js +++ b/public/js/pretty.js @@ -1,3 +1,7 @@ +require('../css/extra.css'); +require('../css/slide-preview.css'); +require('../css/site.css'); + /* other vendors plugin */ var S = require('string'); diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index d03be9c4..c70553be 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -32,9 +32,6 @@ <%- include build/pretty-header %> - - -