Giter Club home page Giter Club logo

Comments (5)

onigoetz avatar onigoetz commented on August 11, 2024 1

Wow, that's a quick answer.

I couldn't do the first one as this configuration is placed in a completely different place.
I will try with with the second one.

Thanks

from webpack-chain.

eliperelman avatar eliperelman commented on August 11, 2024

There are two way I could see doing this.

The first would be to change your rule to add it in the right order:

chain.module.rule('ts')
    .test(/\.tsx?$/)
    .exclude.add(/(node_modules|bower_components)/).end()
    .use("hot").loader("react-hot-loader/webpack")
    .use("ts").loader("ts-loader").options(typeScriptConfigurator())

The second would be a little more low-level if you wanted to modify after the fact. Since JavaScript Maps are iterated in insertion order, you'll need to re-insert the ts-loader. I'm guessing something like this (untested):

const tsRule = chain.module.rule('ts');
const tsLoader = tsRule.use('ts');

tsRule.uses.delete('ts');
tsRule.use('hot').loader('react-hot-loader/webpack');
tsRule.uses.set('ts', tsLoader);

from webpack-chain.

eliperelman avatar eliperelman commented on August 11, 2024

My pleasure!

from webpack-chain.

adambullmer avatar adambullmer commented on August 11, 2024

A better resolution is found in #28, using the .before() chain, to specify before which loader you want to insert. In this case I believe you would resolve it this way:

chain.module.rule("ts")
    .test(/\.tsx?$/)
    .exclude.add(/(node_modules|bower_components)/).end()
    .use("ts").loader("ts-loader").options(typeScriptConfigurator()).before("hot")

I didn't test the if the order of options/before mattered, but doing .loader().before() worked for me

from webpack-chain.

onigoetz avatar onigoetz commented on August 11, 2024

True, this looks easier, anyway react-hot-loader is not a loader anymore so I don't use this anymore :)
But I use webpack-chain a lot in my projects, so this can come in handy

from webpack-chain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.