melMass / craco-raw-loader

This is a craco plugin that makes it easy to use the webpack raw-loader with create-react-app version >= 2.
MIT License
3 stars 2 forks source link

Working with asset modules? #5

Open brahn opened 1 year ago

brahn commented 1 year ago

Hi @melMass -- I see that this plugin is deprecated and wanted to check in about an alternative that seems to work with asset modules react-scripts v5.

I saw your original ticket that motivated creation of this plugin, and used the same form of craco.config.js just swapping out the content of rules based on the webpack documentation regarding source assets:

/* craco.config.js */
module.exports = {
  webpack: {
    alias: {},
    plugins: [],
    mode: "extends",
    configure: {
      module: {
        rules: [
          {
            /* based on https://webpack.js.org/guides/asset-modules/#source-assets */
            test: /\.frag$/,
            type: "asset/source",
          },
        ],
      },
    },
  },
};

This seems to just work -- but I'm new to working with craco so would appreciate any guidance as to whether this approach is advisable and/or any gotcha's I should watch out for.

Thanks!

Droniukas commented 11 months ago

@brahn This honestly helped me so much, no other way of using glsl files in a react project I could find worked for me. I am also interested if this approach is advisable. For me @patricklafrance way of using a function to overwrite the config didn't work and just gave me an error which I didn't manage to fix saying ESLint loader wasn't found.

melMass commented 11 months ago

Hey @brahn sorry for not getting back earlier I'm seing this just now! I guess you solved this by now but it's indeed the way I went using the latest craco (which is still beta afaik).

brahn commented 11 months ago

@melMass thank you! @Droniukas glad it was helpful :-)