Questions tagged [raw-loader]

40 questions
16
votes
6 answers

Webpack: import TypeScript module both "normally" and as raw string

Using webpack ^v2.2.1, I would like to import a TypeScript module as text, in addition to importing the same module "normally". I've figured that I probably should use the raw-loader. But it isn't working out. Some example code: import DemoComponent…
Shahar 'Dawn' Or
  • 2,713
  • 1
  • 26
  • 38
15
votes
3 answers

What exactly am I supposed to do with "module.exports = 'html_template_content'" on webpack

So I want to do a very simple task using webpack. I have a few static HTML templates like e.g. test.html
template content
and all I want to do is return the string inside the template e.g require("raw!./test.html") with…
user3531149
  • 1,519
  • 3
  • 30
  • 48
9
votes
1 answer

Gatsby 3.0: How can I get rid of this yarn / webpack resolver warning?

What happened I've just upgraded gatsby 2 -> 3. Under the hood it now uses webpack 5 instead of 4 and now gives a dependency warning outstanding I just can't get rid of - raw-loader is installed as a dependency of both the main project and of gatsby…
thclark
  • 4,784
  • 3
  • 39
  • 65
7
votes
0 answers

how to compile a javascript file before impoted by raw-loader?

I want to import a .js file as string with raw-loader, however the .js file is written with ES6 module, I want to compile and bundle the file with babel and webpack before import it by raw-loader. In my code, I want to use like: import…
frustigor
  • 392
  • 3
  • 8
6
votes
3 answers

"Cannot find module" when using raw-loader and TypeScript

I'm trying to include some WebGL vertex and fragment shaders by importing them as strings. I have a project structure like this: myproj/ src/ shad/ foo.frg foo.vtx shad.d.ts Foo.ts dist/ ... built/ ... …
trbabb
  • 1,894
  • 18
  • 35
6
votes
1 answer

How to fix the non-working of latest raw-loader version in webpack config?

In my angular project if we use the app is compiling and working fine if we use raw-loader@1.0.0. Whereas if we use version 2.0.0, application is not working. What would be the difference between version 1.0.0 & 2.0.0? webpack.config.ts const…
Alexpandiyan Chokkan
  • 1,025
  • 1
  • 10
  • 30
5
votes
1 answer

Raw loader with ES6 imports

I'm trying to use ES6 with webpack. Its okay for javascript module imports/exports, but I can't get raw-loader to work. Here is what I am intending to do in my source file import template from './template.html' The template.html file has raw HTML…
Nicolas Appriou
  • 2,208
  • 19
  • 32
4
votes
0 answers

Webpack 5 assets modules: raw-loader vs asset/source

I have a basic webpack configuration: module.exports = { context: __dirname, entry: './example.js', experiments: { asset: true, }, output: { path: path.join(__dirname, 'dist'), publicPath: '', filename: 'bundle.js', }, …
PierBJX
  • 2,093
  • 5
  • 19
  • 50
4
votes
1 answer

Webpack raw-loader errors out when require markdown file

raw-loader errors out when attempting to require any .md file. Adding raw loader to import markdown files: test: /\.md$/i, use: [{ loader: 'raw-loader', options: { esModule: false } }], In .js file,…
GN.
  • 8,672
  • 10
  • 61
  • 126
4
votes
0 answers

How can I automate my webpack build to auto escape data URIs in SASS and HTML files?

The issue I am facing is that firefox does not support # characters in data URIs. Chrome or Safari are totally fine with this. Our UI guys have used a lot of inlining of SVGs and these all contain data URIS for example in scss files: content:…
Ranjith Ramachandra
  • 10,399
  • 14
  • 59
  • 96
4
votes
1 answer

Import a cert file as a string using webpack

I was really hoping I'd be able to use webpack to load a certificate file containing text using the raw-loader. Unfortunately it fails at the -'s in the first line: -----BEGIN CERTIFICATE-----. As a test I removed the first -----, and then it fails…
3
votes
1 answer

html-Loader is not working with Webpack 5 + AngularJs (appropriate loader)

I'm trying to load AngularJs app templates(html) using html-loader + webpack 5. Many people junked templateCache favoring html-loader. But in my case I can't really get it work. I even tried raw-loader, angularjs-template-loader and…
3
votes
1 answer

How to use Webpack 2 Raw-Loader to read files

I am currently stuck in a spot where I need to start a NodeJS server in HTTPS mode and need to read in the cert files in order to give them as options in the https.createServer(options, app).listen(8443) command. I am having a hard time grasping…
britztopher
  • 1,214
  • 2
  • 16
  • 26
3
votes
0 answers

Webpack loader cannot find module

Edit 2: The problem is not with webpack but with typescript. Something with declaring "*.md" as a module in a separate declaration file called *.d.ts Edit: Confirmed the issue is not with webpack itself, since I got the following to work: import…
koder
  • 48
  • 1
  • 5
2
votes
1 answer

How do I read raw contents of markdown file into string using webpack 5 and docusaurus

I am currently refactoring a Docusaurus app that displays developer documentation from markdown docs. The app has a "quick start" feature which has a wizard that users fill out info and then it populates a markdown template. The app used to use…
Kevin Patrick
  • 444
  • 1
  • 7
  • 17
1
2 3