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", diff --git a/src/index.js b/src/index.js index 3acdaaf..6b76754 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) { + const regexp = new RegExp(options.modulePathsTest); + const includeModules = []; + + compilation.modules.forEach((mod) => { + const 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: [