SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.26k stars 1.02k forks source link

woff2 files are not loaded correctly via gulp, but load correctly via fast-serve #8992

Open sliziky opened 1 year ago

sliziky commented 1 year ago

Target SharePoint environment

SharePoint Server 2019 (on-premise)

What SharePoint development model, framework, SDK or API is this about?

šŸ’„ SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested

Additional environment details

Describe the bug / error

Hi,

I am developing an on-prem webpart using devextreme, which uses woff2 files for icons. The trouble I have is that if I run the solution via gulp serve... then the icons are not loaded properly. On the other hand, when I run the solution via spfx-fast-serve package then the icons are loaded correctly. This problem occurs only on-prem, I had no trouble with this in shp online.

image

vs

image

I've already created the issue in the fast-serve repo, but unfortunately, it did not help me (link)

gulpfile.js

build.configureWebpack.mergeConfig({
    additionalConfiguration: (generatedConfiguration) => {
      let newConfig = generatedConfiguration;
      generatedConfiguration.plugins.forEach((plugin, i) => {
        if (plugin.options && plugin.options.mangle) {
          generatedConfiguration.plugins.splice(i, 1);
          newConfig = merge(generatedConfiguration, {
            plugins: [
              new TerserPlugin()
            ]
          });
        }
      });
      newConfig.module.rules.push({ 
        test: /\.(png|gif|woff|woff2|eot|ttf|svg)$/, 
        use: "url-loader?name=[name].[ext]"
      }) 
      newConfig.externals = newConfig.externals.filter(name => !(["react", "react-dom"].includes(name)));
      return newConfig;
    }
});
/* fast-serve */
const { addFastServe } = require("spfx-fast-serve-helpers");
addFastServe(build);
/* end of fast-serve */

fast-serve/webpack.extend.js

const webpackConfig = {
  module: {
    rules: [
        { 
          test: /\.(png|gif|woff|woff2|eot|ttf|svg)$/, 
          use: "url-loader?name=[name].[ext]"
        }
    ]
  }
}

copy-static-assets.json

{
  "includeExtensions": [
    "woff2"
  ]
}

Loading fonts in fast-serve is okay, but there is nothing loading (woff2) in gulp mode

fast-serve

image

gulp

image

Steps to reproduce

Expected behavior

1.

ghost commented 1 year ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.