wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

Feature Request - add support for Webpack: File Assets #2685

Open jljorgenson18 opened 3 years ago

jljorgenson18 commented 3 years ago

Issue description or question

Webpack v5 introduced some new ways of handling assets (https://webpack.js.org/guides/asset-modules/). One of the ways behaves a lot like file-loader and copies a file from a source directory into the dist directory, type: 'asset/resource'. That seems to not be working in Wallaby and if you try to fetch the loaded url, the file is not there.

I was able to get around this by setting the assetModuleFilename to match where the file is in the source code

    wallabyWebpackConfig.output = {
        assetModuleFilename: '[path][name][ext]'
    };

but it's not ideal.

Note: This also seems to be a problem when using copy-webpack-plugin as well.

smcenlly commented 3 years ago

Great to hear that you now have all of your tests passing.

Please note that some webpack compilation settings are ignored by Wallaby where they do not make sense in a Wallaby context. Some examples include: Code Splitting, Entry Points, and Output. Due to differences in the Wallaby runtime, you may also need to adjust configuration that writes to the file system (such as CopyWebpackPlugin and Asset Modules) as you have done so that Wallaby can find the files when it runs your tests.

At this stage we do not have any plans (or a technically reasonable way) to support file-loader asset modules outside of changing your configuration or making them available by modifying your Wallaby.js configuration (e.g. with a files pattern).