raw-loader

raw-loader

A loader for webpack that lets you import files as a string.

Install

npm install --save-dev raw-loader

Usage

Use the loader either via your webpack config, CLI or inline.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.txt$/,
        use: 'raw-loader'
      }
    ]
  }
}

In your application

import txt from 'file.txt';

CLI

webpack --module-bind 'txt=raw-loader'

In your application

import txt from 'file.txt';

Inline

In your application

import txt from 'raw-loader!./file.txt';

© JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/loaders/raw-loader

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部