From 2c48e5c42887fecabc01c5f5b6f3dd8e06d3372f Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Tue, 11 Oct 2016 13:19:01 -0700 Subject: [PATCH] Add hard-source-webpack-plugin --- lib/utils/webpack.config.js | 41 +++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 42 insertions(+) diff --git a/lib/utils/webpack.config.js b/lib/utils/webpack.config.js index a1e9416719f98..6347d1a37b23d 100644 --- a/lib/utils/webpack.config.js +++ b/lib/utils/webpack.config.js @@ -6,6 +6,7 @@ import Config from 'webpack-configurator' import ExtractTextPlugin from 'extract-text-webpack-plugin' import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin' import { StatsWriterPlugin } from 'webpack-stats-plugin' +import HardSourceWebpackPlugin from 'hard-source-webpack-plugin' import webpackModifyValidate from './webpack-modify-validate' @@ -109,6 +110,16 @@ module.exports = (program, directory, suppliedStage, webpackPort = 1500, pages = __PREFIX_LINKS__: program.prefixLinks, __LINK_PREFIX__: JSON.stringify(siteDB().get(`config`).linkPrefix), }), + new HardSourceWebpackPlugin({ + cacheDirectory: '/tmp/[confighash]', + recordsPath: '/tmp/[confighash]/records.json', + configHash: (webpackConfig) => stage, + environmentPaths: { + root: process.cwd(), + directories: ['node_modules'], + files: ['package.json'], + }, + }), ] case `build-css`: return [ @@ -120,6 +131,16 @@ module.exports = (program, directory, suppliedStage, webpackPort = 1500, pages = __LINK_PREFIX__: JSON.stringify(siteDB().get(`config`).linkPrefix), }), new ExtractTextPlugin(`styles.css`, { allChunks: true }), + new HardSourceWebpackPlugin({ + cacheDirectory: '/tmp/[confighash]', + recordsPath: '/tmp/[confighash]/records.json', + configHash: (webpackConfig) => stage, + environmentPaths: { + root: process.cwd(), + directories: ['node_modules'], + files: ['package.json'], + }, + }), ] case `build-html`: return [ @@ -132,6 +153,16 @@ module.exports = (program, directory, suppliedStage, webpackPort = 1500, pages = __LINK_PREFIX__: JSON.stringify(siteDB().get(`config`).linkPrefix), }), new ExtractTextPlugin(`build-html-styles.css`), + new HardSourceWebpackPlugin({ + cacheDirectory: '/tmp/[confighash]', + recordsPath: '/tmp/[confighash]/records.json', + configHash: (webpackConfig) => stage, + environmentPaths: { + root: process.cwd(), + directories: ['node_modules'], + files: ['package.json'], + }, + }), ] case `build-javascript`: { // Get array of page template component names. @@ -215,6 +246,16 @@ module.exports = (program, directory, suppliedStage, webpackPort = 1500, pages = events: true, }, }), + new HardSourceWebpackPlugin({ + cacheDirectory: '/tmp/[confighash]', + recordsPath: '/tmp/[confighash]/records.json', + configHash: (webpackConfig) => stage, + environmentPaths: { + root: process.cwd(), + directories: ['node_modules'], + files: ['package.json'], + }, + }), ] } default: diff --git a/package.json b/package.json index 4f8285c947b71..fa9b0342b42d5 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "graphql-relay": "^0.4.3", "hapi": "^8.5.1", "hapi-graphql": "^1.0.1", + "hard-source-webpack-plugin": "^0.1.0", "highlight.js": "^9.6.0", "history": "^2.1.2", "invariant": "^2.2.1",