rc-source-loader
A loader for webpack that allows importing files as a String
Last updated 7 years ago by chenshuai2144 .
MIT · Repository · Bugs · Original npm
$ cnpm install rc-source-loader 
SYNC missed versions from official npm registry.

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);

Current Tags

  • 1.0.2                                ...           latest (7 years ago)

1 Versions

  • 1.0.2                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (23)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org