Browse Source

Only CSS references need to traverse

The path adjustment for assets in bundles is only needed with CSS files.  Paths
referenced in JS files are written to elements, where they are relative to the
document.
pull/8166/head
J. Ryan Stinnett 3 years ago
parent
commit
cf0b2816c1
  1. 17
      webpack.config.js

17
webpack.config.js

@ -59,25 +59,26 @@ module.exports = {
// lifetime for assets while still delivering changes quickly.
oneOf: [
{
// Images referenced in HTML files
issuer: /\.html$/,
// Images referenced in CSS files
issuer: /\.(scss|css)$/,
loader: 'file-loader',
options: {
name: '[name].[hash:7].[ext]',
outputPath: getImgOutputPath,
publicPath: function(url, resourcePath) {
// CSS image usages end up in the `bundles/[hash]` output
// directory, so we adjust the final path to navigate up
// twice.
return path.join("../..", getImgOutputPath(url, resourcePath));
},
},
},
{
// Images referenced in JS and CSS files
// Images referenced in HTML and JS files
loader: 'file-loader',
options: {
name: '[name].[hash:7].[ext]',
outputPath: getImgOutputPath,
publicPath: function(url, resourcePath) {
// JS and CSS image usages end up the `bundles/[hash]` output
// directory, so we adjust the final path to navigate up twice.
return path.join("../..", getImgOutputPath(url, resourcePath));
},
},
},
],

Loading…
Cancel
Save