raw-loader
A loader for webpack that lets you import files as a string.
安装
npm install --save-dev raw-loader
用法
通过 webpack 配置、命令行或者内联使用 loader。
##
webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.txt$/,
        use: 'raw-loader'
      }
    ]
  }}在你的项目中
import txt from './file.txt';
通过命令行(CLI)
webpack --module-bind 'txt=raw-loader'
在你的项目中
import txt from 'file.txt';
内联使用
在你的项目中
import txt from 'raw-loader!./file.txt';
