Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Created July 24, 2018 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remarkablemark/13450bd0118863b6501756eee3506aa3 to your computer and use it in GitHub Desktop.
Save remarkablemark/13450bd0118863b6501756eee3506aa3 to your computer and use it in GitHub Desktop.
Import raw JavaScript file using Webpack raw-loader.

Give JS file:

// foo.js
console.log('foo');

To import the CommonJS way:

const rawFoo = require('raw-loader!./foo.js');

To import the ES Modules way:

import rawFoo from 'raw-loader!./foo.js';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment