@@ -5,6 +5,7 @@ const nodeExternals = require('webpack-node-externals');
5
5
const webpack = require ( 'webpack' ) ;
6
6
7
7
const DEFAULT_CHUNK_FILENAME = 'chunks/[name].[chunkhash].js' ;
8
+ const DEFAULT_ASSET_FILENAME = 'assets/[name].[hash][ext][query]' ;
8
9
9
10
/**
10
11
* @typedef {import('webpack').Configuration } Configuration
@@ -70,6 +71,7 @@ class ScratchWebpackConfigBuilder {
70
71
output : {
71
72
clean : true ,
72
73
filename : '[name].js' ,
74
+ assetModuleFilename : DEFAULT_ASSET_FILENAME ,
73
75
chunkFilename : DEFAULT_CHUNK_FILENAME ,
74
76
path : this . _distPath ,
75
77
library : {
@@ -116,26 +118,39 @@ class ScratchWebpackConfigBuilder {
116
118
{
117
119
// `asset` automatically chooses between exporting a data URI and emitting a separate file.
118
120
// 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' ,
120
123
type : 'asset'
121
124
} ,
122
125
{
123
126
// `asset/resource` emits a separate file and exports the URL.
124
127
// Previously achievable by using `file-loader`.
128
+ // Output is saved with the default asset module filename.
125
129
resourceQuery : / ^ \? ( r e s o u r c e | f i l e ) $ / ,
126
130
type : 'asset/resource'
127
131
} ,
128
132
{
129
133
// `asset/inline` exports a data URI of the asset.
130
134
// Previously achievable by using `url-loader`.
135
+ // Because the file is inlined, there is no filename.
131
136
resourceQuery : / ^ \? ( i n l i n e | u r l ) $ / ,
132
137
type : 'asset/inline'
133
138
} ,
134
139
{
135
140
// `asset/source` exports the source code of the asset.
136
141
// Previously achievable by using `raw-loader`.
137
142
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'
139
154
} ,
140
155
{
141
156
test : / \. h e x $ / ,
0 commit comments