From c1bb2b3a27bd97feb4a30db3969cfc1156ee4138 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sun, 6 Nov 2016 20:32:47 -0800 Subject: [PATCH] Switch assets manifest plugin --- .../build/util/assetsPluginProcessOutput.js | 19 --- assets/build/webpack.config.production.js | 48 +++++- package.json | 6 +- yarn.lock | 148 +++++++----------- 4 files changed, 98 insertions(+), 123 deletions(-) delete mode 100644 assets/build/util/assetsPluginProcessOutput.js diff --git a/assets/build/util/assetsPluginProcessOutput.js b/assets/build/util/assetsPluginProcessOutput.js deleted file mode 100644 index 246efd7a20..0000000000 --- a/assets/build/util/assetsPluginProcessOutput.js +++ /dev/null @@ -1,19 +0,0 @@ - -const path = require('path'); - -/** - * Process AssetsPlugin output and format it - * for Sage: {"[name].[ext]":"[name]_[hash].[ext]"} - * @param {Object} assets passed by processOutput - * @return {String} JSON - */ -module.exports = (assets) => { - const manifest = {}; - Object.keys(assets).forEach((name) => { - Object.keys(assets[name]).forEach((ext) => { - const filename = `${path.dirname(assets[name][ext])}/${path.basename(`${name}.${ext}`)}`; - manifest[filename] = assets[name][ext]; - }); - }); - return manifest; -}; diff --git a/assets/build/webpack.config.production.js b/assets/build/webpack.config.production.js index e3f23ec59f..346cf7e13a 100644 --- a/assets/build/webpack.config.production.js +++ b/assets/build/webpack.config.production.js @@ -1,18 +1,50 @@ -const AssetsPlugin = require('assets-webpack-plugin'); +'use strict'; // eslint-disable-line + +const WebpackAssetsManifest = require('webpack-assets-manifest'); const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const cssnano = require('cssnano'); +const path = require('path'); -const processOutput = require('./util/assetsPluginProcessOutput'); const config = require('./config'); module.exports = { plugins: [ - new AssetsPlugin({ - path: config.paths.dist, - filename: 'assets.json', - fullPath: false, - processOutput(assets) { - return JSON.stringify(Object.assign(processOutput(assets), config.manifest)); + new WebpackAssetsManifest({ + output: 'assets.json', + space: 2, + writeToDisk: false, + assets: config.manifest, + replacer(key, value) { + if (typeof value === 'string') { + return value; + } + const manifest = value; + /** + * Hack to prepend scripts/ or styles/ to manifest keys + * + * This might need to be reworked at some point. + * + * Before: + * { + * "main.js": "scripts/main_abcdef.js" + * "main.css": "styles/main_abcdef.css" + * } + * After: + * { + * "scripts/main.js": "scripts/main_abcdef.js" + * "styles/main.css": "styles/main_abcdef.css" + * } + */ + Object.keys(manifest).forEach((src) => { + const sourcePath = path.basename(path.dirname(src)); + const targetPath = path.basename(path.dirname(manifest[src])); + if (sourcePath === targetPath) { + return; + } + manifest[`${targetPath}/${src}`] = manifest[src]; + delete manifest[src]; + }); + return manifest; }, }), new OptimizeCssAssetsPlugin({ diff --git a/package.json b/package.json index bfdeb6662f..31afd82c8d 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,7 @@ "node": ">= 4.5" }, "devDependencies": { - "assets-webpack-plugin": "^3.5.0", - "autoprefixer": "^6.5.1", + "autoprefixer": "^6.5.2", "body-parser": "^1.15.2", "browser-sync": "^2.17.5", "buble": "^0.14.2", @@ -43,7 +42,7 @@ "eslint-loader": "^1.6.1", "eslint-plugin-import": "^2.0.1", "eslint-plugin-jsx-a11y": "^2.2.3", - "eslint-plugin-react": "^6.5.0", + "eslint-plugin-react": "^6.6.0", "extract-text-webpack-plugin": "^2.0.0-beta.4", "file-loader": "^0.9.0", "glob": "^7.1.1", @@ -65,6 +64,7 @@ "style-loader": "^0.13.1", "url-loader": "^0.5.7", "webpack": "^2.1.0-beta.25", + "webpack-assets-manifest": "^0.5.0", "webpack-dev-middleware": "^1.8.4", "webpack-hot-middleware": "^2.13.1" }, diff --git a/yarn.lock b/yarn.lock index 0f74c70d0f..4229baa0d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -156,8 +156,8 @@ arrify@^1.0.0: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" asn1.js@^4.0.0: - version "4.8.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.8.1.tgz#3949b7f5fd1e8bedc13be3abebf477f93490c810" + version "4.9.0" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.0.tgz#f71a1243f3e79d46d7b07d7fbf4824ee73af054a" dependencies: bn.js "^4.0.0" inherits "^2.0.1" @@ -189,16 +189,6 @@ assert@^1.1.1: dependencies: util "0.10.3" -assets-webpack-plugin: - version "3.5.0" - resolved "https://registry.yarnpkg.com/assets-webpack-plugin/-/assets-webpack-plugin-3.5.0.tgz#933b16bf679c7510dd3475e4df9ba495d9dc0368" - dependencies: - camelcase "^1.2.1" - escape-string-regexp "^1.0.3" - lodash.assign "^3.2.0" - lodash.merge "^3.3.2" - mkdirp "^0.5.1" - async-each-series@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/async-each-series/-/async-each-series-1.1.0.tgz#f42fd8155d38f21a5b8ea07c28e063ed1700b138" @@ -215,7 +205,7 @@ async-foreach@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/async-foreach/-/async-foreach-0.1.3.tgz#36121f845c0578172de419a97dbeb1d16ec34542" -async-throttle@zeit/async-throttle#596dc23b4ac2598cfed4d30289fb75c29f8d57fe: +"async-throttle@github:zeit/async-throttle#596dc23b4ac2598cfed4d30289fb75c29f8d57fe": version "0.0.1" resolved "https://codeload.github.com/zeit/async-throttle/tar.gz/596dc23b4ac2598cfed4d30289fb75c29f8d57fe" @@ -251,15 +241,15 @@ atob@~1.1.0: version "1.1.3" resolved "https://registry.yarnpkg.com/atob/-/atob-1.1.3.tgz#95f13629b12c3a51a5d215abdce2aa9f32f80773" -autoprefixer@^6.3.1, autoprefixer@^6.5.1: - version "6.5.1" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-6.5.1.tgz#ae759a5221e709f3da17c2d656230e67c43cbb75" +autoprefixer@^6.3.1, autoprefixer@^6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-6.5.2.tgz#37cc910c5e1139ad341a006d5f6d441a380b742b" dependencies: browserslist "~1.4.0" - caniuse-db "^1.0.30000554" + caniuse-db "^1.0.30000576" normalize-range "^0.1.2" num2fraction "^1.2.2" - postcss "^5.2.4" + postcss "^5.2.5" postcss-value-parser "^3.2.3" aws-sign2@~0.6.0: @@ -659,9 +649,9 @@ camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" -caniuse-db@^1.0.30000539, caniuse-db@^1.0.30000554: - version "1.0.30000574" - resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000574.tgz#4b10fb5435c50262effd10653405befd0d0bfc2c" +caniuse-db@^1.0.30000539, caniuse-db@^1.0.30000576: + version "1.0.30000576" + resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000576.tgz#c0623997f6b1ff3b56fa33b352fe44874f61c0ce" capture-stack-trace@^1.0.0: version "1.0.0" @@ -1515,7 +1505,7 @@ escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.3, escape-string-regexp@^1.0.5: +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -1585,9 +1575,9 @@ eslint-plugin-jsx-a11y@^2.2.3: jsx-ast-utils "^1.0.0" object-assign "^4.0.1" -eslint-plugin-react@^6.5.0: - version "6.5.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.5.0.tgz#93f894b6469974304609e59c8983a6a3dc81738c" +eslint-plugin-react@^6.6.0: + version "6.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.6.0.tgz#91ceecefa8a22d8f5d23ef9a839516a7d9fa63a1" dependencies: doctrine "^1.2.2" jsx-ast-utils "^1.3.3" @@ -2044,17 +2034,6 @@ gifsicle@^3.0.0: bin-wrapper "^3.0.0" logalot "^2.0.0" -glob, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@~7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.2" - once "^1.3.0" - path-is-absolute "^1.0.0" - glob-base@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" @@ -2098,6 +2077,17 @@ glob@^5.0.3: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@~7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + globals@^9.2.0: version "9.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.12.0.tgz#992ce90828c3a55fa8f16fada177adb64664cf9d" @@ -2888,7 +2878,7 @@ loader-runner@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.2.0.tgz#824c1b699c4e7a2b6501b85902d5b862bf45b3fa" -loader-utils, loader-utils@^0.2.11, loader-utils@^0.2.12, loader-utils@^0.2.15, loader-utils@^0.2.16, loader-utils@^0.2.3, loader-utils@^0.2.7, loader-utils@~0.2.2, loader-utils@~0.2.5, loader-utils@0.2.x: +loader-utils@^0.2.11, loader-utils@^0.2.12, loader-utils@^0.2.15, loader-utils@^0.2.16, loader-utils@^0.2.3, loader-utils@^0.2.7, loader-utils@~0.2.2, loader-utils@~0.2.5, loader-utils@0.2.x: version "0.2.16" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d" dependencies: @@ -2906,14 +2896,6 @@ localtunnel@1.8.1: request "2.65.0" yargs "3.29.0" -lodash._arraycopy@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1" - -lodash._arrayeach@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz#bab156b2a90d3f1bbd5c653403349e5e5933ef9e" - lodash._baseassign@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" @@ -2925,10 +2907,6 @@ lodash._basecopy@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" -lodash._basefor@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash._basefor/-/lodash._basefor-3.0.3.tgz#7550b4e9218ef09fad24343b612021c79b4c20c2" - lodash._basetostring@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5" @@ -2980,7 +2958,7 @@ lodash._root@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" -lodash.assign@^3.0.0, lodash.assign@^3.2.0: +lodash.assign@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-3.2.0.tgz#3ce9f0234b4b2223e296b8fa0ac1fee8ebca64fa" dependencies: @@ -3025,6 +3003,10 @@ lodash.escape@^3.0.0: dependencies: lodash._root "^3.0.0" +lodash.get@^4.0: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + lodash.indexof@^4.0.5: version "4.0.5" resolved "https://registry.yarnpkg.com/lodash.indexof/-/lodash.indexof-4.0.5.tgz#53714adc2cddd6ed87638f893aa9b6c24e31ef3c" @@ -3041,18 +3023,6 @@ lodash.isequal@^4.0.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.4.0.tgz#6295768e98e14dc15ce8d362ef6340db82852031" -lodash.isplainobject@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz#9a8238ae16b200432960cd7346512d0123fbf4c5" - dependencies: - lodash._basefor "^3.0.0" - lodash.isarguments "^3.0.0" - lodash.keysin "^3.0.0" - -lodash.istypedarray@^3.0.0: - version "3.0.6" - resolved "https://registry.yarnpkg.com/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz#c9a477498607501d8e8494d283b87c39281cef62" - lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" @@ -3061,32 +3031,21 @@ lodash.keys@^3.0.0: lodash.isarguments "^3.0.0" lodash.isarray "^3.0.0" -lodash.keysin@^3.0.0: - version "3.0.8" - resolved "https://registry.yarnpkg.com/lodash.keysin/-/lodash.keysin-3.0.8.tgz#22c4493ebbedb1427962a54b445b2c8a767fb47f" - dependencies: - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" +lodash.keys@^4.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-4.2.0.tgz#a08602ac12e4fb83f91fc1fb7a360a4d9ba35205" lodash.map@4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" -lodash.merge@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-3.3.2.tgz#0d90d93ed637b1878437bb3e21601260d7afe994" - dependencies: - lodash._arraycopy "^3.0.0" - lodash._arrayeach "^3.0.0" - lodash._createassigner "^3.0.0" - lodash._getnative "^3.0.0" - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" - lodash.isplainobject "^3.0.0" - lodash.istypedarray "^3.0.0" - lodash.keys "^3.0.0" - lodash.keysin "^3.0.0" - lodash.toplainobject "^3.0.0" +lodash.merge@^4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5" + +lodash.pick@^4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" lodash.restparam@^3.0.0: version "3.6.1" @@ -3113,13 +3072,6 @@ lodash.templatesettings@^3.0.0: lodash._reinterpolate "^3.0.0" lodash.escape "^3.0.0" -lodash.toplainobject@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash.toplainobject/-/lodash.toplainobject-3.0.0.tgz#28790ad942d293d78aa663a07ecf7f52ca04198d" - dependencies: - lodash._basecopy "^3.0.0" - lodash.keysin "^3.0.0" - lodash.words@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash.words/-/lodash.words-3.2.0.tgz#4e2a8649bc08745b17c695b1a3ce8fee596623b3" @@ -3520,8 +3472,8 @@ object-component@0.0.3: resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" object-hash@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.1.4.tgz#136f07f1a48af5f6b906812451ae4e43978c94aa" + version "1.1.5" + resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.1.5.tgz#bdd844e030d0861b692ca175c6cab6868ec233d7" object-path@^0.9.0: version "0.9.2" @@ -4039,7 +3991,7 @@ postcss-zindex@^2.0.1: postcss "^5.0.4" uniqs "^2.0.0" -postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0.14, postcss@^5.0.16, postcss@^5.0.2, postcss@^5.0.4, postcss@^5.0.5, postcss@^5.0.6, postcss@^5.0.8, postcss@^5.2.4, postcss@^5.2.5: +postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0.14, postcss@^5.0.16, postcss@^5.0.2, postcss@^5.0.4, postcss@^5.0.5, postcss@^5.0.6, postcss@^5.0.8, postcss@^5.2.5: version "5.2.5" resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.5.tgz#ec428c27dffc7fac65961340a9b022fa4af5f056" dependencies: @@ -5272,6 +5224,16 @@ watchpack@^1.0.0: chokidar "^1.4.3" graceful-fs "^4.1.2" +webpack-assets-manifest@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/webpack-assets-manifest/-/webpack-assets-manifest-0.5.0.tgz#b2f193d680b3f3a98e61ca787fcc9fac18aa546d" + dependencies: + lodash.get "^4.0" + lodash.keys "^4.0" + lodash.merge "^4.0" + lodash.pick "^4.0" + mkdirp "^0.5.1" + webpack-dev-middleware@^1.8.4: version "1.8.4" resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.8.4.tgz#e8765c9122887ce9e3abd4cc9c3eb31b61e0948d"