@@ -30,6 +30,16 @@ const htmlWebpackPluginCommon = {
3030// When this changes, the path for all JS files will change, bypassing any HTTP caches
3131const CACHE_EPOCH = 'pentapod' ;
3232
33+ /*
34+ * scratch-storage resolves to its source (the alias below), and its source requires three files
35+ * it falls back to when an asset cannot be loaded -- the grey question mark, the empty vector,
36+ * the silent sound -- expecting arraybuffers, as its own build gives it. This config's url-loader
37+ * would hand it data-URI strings instead, and Buffer.from(string) makes a "default costume" out of
38+ * the text of a data URI, which is not an SVG. Every project with one missing costume then
39+ * failed to load outright, where it used to show a blank costume.
40+ */
41+ const STORAGE_BUILTINS = / s c r a t c h - s t o r a g e [ \\ / ] s r c [ \\ / ] b u i l t i n s [ \\ / ] / ;
42+
3343const base = {
3444 mode : process . env . NODE_ENV === 'production' ? 'production' : 'development' ,
3545 devtool : process . env . SOURCEMAP || ( process . env . NODE_ENV === 'production' ? false : 'cheap-module-source-map' ) ,
@@ -93,6 +103,11 @@ const base = {
93103 presets : [ '@babel/preset-env' , '@babel/preset-react' ]
94104 }
95105 } ,
106+ {
107+ test : / \. ( p n g | s v g | w a v ) $ / ,
108+ include : STORAGE_BUILTINS ,
109+ loader : 'arraybuffer-loader'
110+ } ,
96111 {
97112 test : / \. c s s $ / ,
98113 use : [ {
@@ -163,6 +178,7 @@ module.exports = [
163178 rules : base . module . rules . concat ( [
164179 {
165180 test : / \. ( s v g | p n g | w a v | m p 3 | g i f | j p g | w o f f 2 | h e x | m p 4 ) $ / ,
181+ exclude : STORAGE_BUILTINS ,
166182 loader : 'url-loader' ,
167183 options : {
168184 limit : 2048 ,
@@ -287,6 +303,7 @@ module.exports = [
287303 rules : base . module . rules . concat ( [
288304 {
289305 test : / \. ( s v g | p n g | w a v | m p 3 | g i f | j p g | w o f f 2 | h e x | m p 4 ) $ / ,
306+ exclude : STORAGE_BUILTINS ,
290307 loader : 'url-loader' ,
291308 options : {
292309 limit : 2048 ,
0 commit comments