From bdbd8f8fb983dfcbc215c50a54533bf379a6eb51 Mon Sep 17 00:00:00 2001 From: qwe Date: Thu, 26 Oct 2017 23:34:34 +0200 Subject: [PATCH 1/3] Dynamically add chunk paths with regex --- src/index.js | 21 ++++++++++++++++++++- src/schema.js | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 3acdaaf..ee965a6 100644 --- a/src/index.js +++ b/src/index.js @@ -21,7 +21,8 @@ module.exports = function PurifyPlugin(options) { } compiler.plugin('this-compilation', (compilation) => { - const entryPaths = parse.entryPaths(options.paths); + let entryPaths = parse.entryPaths(options.paths); + parse.flatten(entryPaths).forEach((p) => { if (!fs.existsSync(p)) throw new Error(`Path ${p} does not exist.`); @@ -34,6 +35,24 @@ module.exports = function PurifyPlugin(options) { () => {}; compilation.plugin('additional-assets', (cb) => { + // Go through chunks and include them to the paths that will be parsed + if (options.modulePathsTest) { + let regexp = new RegExp(options.modulePathsTest) + let includeModules = [] + + compilation.modules.forEach(mod => { + let res = mod.resource + + if (regexp.test(res)) { + includeModules.push(res) + } + }) + + if (includeModules.length) { + entryPaths = entryPaths.concat(includeModules) + } + } + // Go through chunks and purify as configured compilation.chunks.forEach( ({ name: chunkName, files, modules }) => { diff --git a/src/schema.js b/src/schema.js index cce104d..8ce2bb3 100644 --- a/src/schema.js +++ b/src/schema.js @@ -26,6 +26,9 @@ const schema = ({ entry } = {}) => ({ }, verbose: { type: 'boolean' + }, + modulePathsTest: { + type: 'string' } }, required: [ From 82832e48f910fae79fdd9a1eeae9ea25d47501ba Mon Sep 17 00:00:00 2001 From: qwe Date: Thu, 26 Oct 2017 23:45:36 +0200 Subject: [PATCH 2/3] Linting fixes --- src/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index ee965a6..6b76754 100644 --- a/src/index.js +++ b/src/index.js @@ -37,19 +37,19 @@ module.exports = function PurifyPlugin(options) { compilation.plugin('additional-assets', (cb) => { // Go through chunks and include them to the paths that will be parsed if (options.modulePathsTest) { - let regexp = new RegExp(options.modulePathsTest) - let includeModules = [] + const regexp = new RegExp(options.modulePathsTest); + const includeModules = []; - compilation.modules.forEach(mod => { - let res = mod.resource + compilation.modules.forEach((mod) => { + const res = mod.resource; if (regexp.test(res)) { - includeModules.push(res) + includeModules.push(res); } - }) + }); if (includeModules.length) { - entryPaths = entryPaths.concat(includeModules) + entryPaths = entryPaths.concat(includeModules); } } From 760b50c4369fcf63628df9cd7641446c9d5543db Mon Sep 17 00:00:00 2001 From: qwe Date: Thu, 26 Oct 2017 23:56:08 +0200 Subject: [PATCH 3/3] Install missing node_modules --- package.json | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bb6ddef..f21c711 100644 --- a/package.json +++ b/package.json @@ -59,16 +59,25 @@ "babel-plugin-syntax-object-rest-spread": "^6.13.0", "babel-plugin-transform-object-rest-spread": "^6.20.2", "babel-preset-es2015": "^6.18.0", - "eslint": "^3.13.1", - "eslint-config-airbnb": "^14.0.0", - "eslint-plugin-import": "^2.2.0", + "eslint": "^3.19.0", + "eslint-config-airbnb": "^14.1.0", + "eslint-config-standard": "^10.2.1", + "eslint-plugin-html": "^3.2.2", + "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^3.0.2", - "eslint-plugin-react": "^6.9.0", + "eslint-plugin-node": "^5.2.1", + "eslint-plugin-promise": "^3.6.0", + "eslint-plugin-react": "^6.10.3", + "eslint-plugin-standard": "^3.0.1", + "extract-text-webpack-plugin": "^3.0.2", "git-prepush-hook": "^1.0.1", "jest": "^18.1.0", "npm-watch": "^0.1.8", + "purecss": "^1.0.0", "purify-css": "^1.2.2", - "rimraf": "^2.6.1" + "rimraf": "^2.6.1", + "webpack": "^3.8.1", + "webpack-merge": "^4.1.0" }, "pre-push": [ "build",