-
-
Notifications
You must be signed in to change notification settings - Fork 199
Implement assets webpack plugin #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,27 +9,46 @@ | |
|
||
'use strict'; | ||
|
||
const EntryFilesManifestPlugin = require('../webpack/entry-files-manifest-plugin'); | ||
const PluginPriorities = require('./plugin-priorities'); | ||
const path = require('path'); | ||
const sharedEntryTmpName = require('../utils/sharedEntryTmpName'); | ||
const copyEntryTmpName = require('../utils/copyEntryTmpName'); | ||
const manifestKeyPrefixHelper = require('../utils/manifest-key-prefix-helper'); | ||
const AssetsPlugin = require('assets-webpack-plugin'); | ||
|
||
function processOutput(assets) { | ||
if (assets.hasOwnProperty(copyEntryTmpName)) { | ||
delete assets[copyEntryTmpName]; | ||
} | ||
if (assets.hasOwnProperty(sharedEntryTmpName)) { | ||
delete assets[sharedEntryTmpName]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now need to delete one other "magic: entry that may exist :) #409 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will get this done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Altered the function to take care of this issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weaverryan Is the any other files we need to delete from the output? |
||
} | ||
// This will iterate over all the entry points and remove the / from the start of the paths. It also converts the | ||
// one file entries into an array of one entry since that was how the entry point file was before this change. | ||
for (const asset in assets) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a little comment about what this is doing / why? And, if I understand it correctly, this gives us complete control over the output, right? Could we "correct" the output so that if there's only one entry, it's always an array? That would remove one of the slightly weird edge-cases that the bundle would need to handle. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true I never thought of that. Yes we could turn it into an array. I will add that to this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the function to now put the single instances into an array. I also out a comment above the loop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weaverryan Is there anything else we need to do to the output? |
||
for (const fileType in assets[asset]) { | ||
if (Array.isArray(assets[asset][fileType])) { | ||
assets[asset][fileType] = assets[asset][fileType].map(buildPath => buildPath.replace(/^\//g, '')); | ||
} else { | ||
assets[asset][fileType] = [assets[asset][fileType].replace(/^\//g, '')]; | ||
} | ||
} | ||
} | ||
return JSON.stringify(assets); | ||
} | ||
|
||
/** | ||
* @param {Array} plugins | ||
* @param {WebpackConfig} webpackConfig | ||
* @return {void} | ||
*/ | ||
module.exports = function(plugins, webpackConfig) { | ||
|
||
plugins.push({ | ||
plugin: new EntryFilesManifestPlugin( | ||
path.join(webpackConfig.outputPath, 'entrypoints.json'), | ||
manifestKeyPrefixHelper(webpackConfig), | ||
[sharedEntryTmpName, copyEntryTmpName], | ||
webpackConfig.styleEntries | ||
), | ||
priority: PluginPriorities.EntryFilesManifestPlugin | ||
plugin: new AssetsPlugin({ | ||
path: webpackConfig.outputPath, | ||
filename: 'entrypoints.json', | ||
includeAllFileTypes: true, | ||
entrypoints: true, | ||
processOutput: processOutput | ||
}), | ||
priority: PluginPriorities.AssetsPlugin | ||
}); | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1238,6 +1238,17 @@ assertion-error@^1.0.1: | |
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" | ||
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== | ||
|
||
assets-webpack-plugin@^3.9.7: | ||
version "3.9.7" | ||
resolved "https://registry.yarnpkg.com/assets-webpack-plugin/-/assets-webpack-plugin-3.9.7.tgz#0c3c13632cc4490b2ef79fd0bbb16c69a724f364" | ||
integrity sha512-yxo4MlSb++B88qQFE27Wf56ykGaDHZeKcSbrstSFOOwOxv33gWXtM49+yfYPSErlXPAMT5lVy3YPIhWlIFjYQw== | ||
dependencies: | ||
camelcase "^5.0.0" | ||
escape-string-regexp "^1.0.3" | ||
lodash.assign "^4.2.0" | ||
lodash.merge "^4.6.1" | ||
mkdirp "^0.5.1" | ||
|
||
assign-symbols@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" | ||
|
@@ -1719,6 +1730,11 @@ camelcase@^4.1.0: | |
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" | ||
integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= | ||
|
||
camelcase@^5.0.0: | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" | ||
integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA== | ||
|
||
caniuse-api@^1.5.2: | ||
version "1.6.1" | ||
resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-1.6.1.tgz#b534e7c734c4f81ec5fbe8aca2ad24354b962c6c" | ||
|
@@ -2894,7 +2910,7 @@ escape-html@~1.0.3: | |
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" | ||
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= | ||
|
||
[email protected], escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: | ||
[email protected], escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.3, 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" | ||
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= | ||
|
@@ -5016,6 +5032,11 @@ lodash.memoize@^4.1.2: | |
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" | ||
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= | ||
|
||
lodash.merge@^4.6.1: | ||
version "4.6.1" | ||
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" | ||
integrity sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ== | ||
|
||
lodash.mergewith@^4.6.0: | ||
version "4.6.1" | ||
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927" | ||
|
Uh oh!
There was an error while loading. Please reload this page.