Webpack - ignore loaders in require()?

后端 未结 3 837
轮回少年
轮回少年 2021-01-12 14:11

I have a TypeScript project which I am bundling with Webpack. It is a demo/docs app for an open source lib I am writing, so I want to show some of the source code as part of

相关标签:
3条回答
  • 2021-01-12 14:29

    Is there a proper way to tell webpack to "ignore" loaders in specific require cases?

    Yes. Update your test in { test: /\.ts$/, loader: 'ts'}, as desired.

    0 讨论(0)
  • 2021-01-12 14:36

    You can add two exclamation to ignore loaders in the webpack config file

    !!raw!file.ts

    one exclamation will only disable preloaders!

    https://webpack.js.org/concepts/loaders/#inline

    0 讨论(0)
  • 2021-01-12 14:50

    As far as I know that is the only way you are going to be able to load a file in two different ways. I expect the issue is that your paths are different in your production build.

    I would suggest running webpack with the --display-error-details flag to get more info on why it fails.

    0 讨论(0)
提交回复
热议问题