包详细信息

rc-source-loader

webpack-contrib739MIT1.0.2

A loader for webpack that allows importing files as a String

自述文件

rc-source-loader

This package can directly read the source code of the file. Without any conversion

demo.js

export default function generateErrorTemplate(err) {
  const strToHtml = (str) =>
    (str || '')
      .replace(/&/g, '&')
      .replace(/</g, '<')
      .replace(/>/g, '>')
      .replace(/"/g, '')
      .replace(/'/g, "'")
      .replace(/\[(\d+)m/g, '')
      .replace(/ /g, ' ')
      .replace(/\n/g, '<br />');
  const template = `
          <!DOCTYPE html> 
          <html>
          <head>
          </head>
          <body>
            <div>
              ${strToHtml(err.toString()) || ''}
            </div>
          </body>
          </html>`;
  return template;
}

Use

import demo from 'rrc-source-loader!./demo.js';
// Directly output the contents of this js
console.log(demo);

更新日志

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.0.2 (2019-01-07)

1.0.1 (2019-01-07)

1.0.0 (2018-12-10)

Bug Fixes

Features

BREAKING CHANGES

  • minimum require webpack version is 4
  • minimum require nodejs version is 6.9