@@ -5,6 +5,7 @@ const nodeExternals = require('webpack-node-externals');
55const webpack = require ( 'webpack' ) ;
66
77const DEFAULT_CHUNK_FILENAME = 'chunks/[name].[chunkhash].js' ;
8+ const DEFAULT_ASSET_FILENAME = 'assets/[name].[hash][ext][query]' ;
89
910/**
1011 * @typedef {import('webpack').Configuration } Configuration
@@ -70,6 +71,7 @@ class ScratchWebpackConfigBuilder {
7071 output : {
7172 clean : true ,
7273 filename : '[name].js' ,
74+ assetModuleFilename : DEFAULT_ASSET_FILENAME ,
7375 chunkFilename : DEFAULT_CHUNK_FILENAME ,
7476 path : this . _distPath ,
7577 library : {
@@ -116,26 +118,39 @@ class ScratchWebpackConfigBuilder {
116118 {
117119 // `asset` automatically chooses between exporting a data URI and emitting a separate file.
118120 // Previously achievable by using `url-loader` with asset size limit.
119- resourceQuery : / ^ \? a s s e t $ / ,
121+ // If file output is chosen, it is saved with the default asset module filename.
122+ resourceQuery : '?asset' ,
120123 type : 'asset'
121124 } ,
122125 {
123126 // `asset/resource` emits a separate file and exports the URL.
124127 // Previously achievable by using `file-loader`.
128+ // Output is saved with the default asset module filename.
125129 resourceQuery : / ^ \? ( r e s o u r c e | f i l e ) $ / ,
126130 type : 'asset/resource'
127131 } ,
128132 {
129133 // `asset/inline` exports a data URI of the asset.
130134 // Previously achievable by using `url-loader`.
135+ // Because the file is inlined, there is no filename.
131136 resourceQuery : / ^ \? ( i n l i n e | u r l ) $ / ,
132137 type : 'asset/inline'
133138 } ,
134139 {
135140 // `asset/source` exports the source code of the asset.
136141 // Previously achievable by using `raw-loader`.
137142 resourceQuery : / ^ \? ( s o u r c e | r a w ) $ / ,
138- type : 'asset/source'
143+ type : 'asset/source' ,
144+ generator : {
145+ // This filename seems unused, but if it ever gets used,
146+ // its extension should not match the asset's extension.
147+ filename : DEFAULT_ASSET_FILENAME + '.js'
148+ }
149+ } ,
150+ {
151+ resourceQuery : '?arrayBuffer' ,
152+ type : 'javascript/auto' ,
153+ use : 'arraybuffer-loader'
139154 } ,
140155 {
141156 test : / \. h e x $ / ,
0 commit comments