Webpack loader that exports the source directly
Note: This project is in early development, and versioning is a little different. Read this for more details.
If you need to load up a file's source directly and have it available within your javascript, this loader is what you're after. For example, you could load up a svg file, parse out a path you want, and manipulate that with your javascript somehow. Or you could load up a json or text file. Or some other type of file that you came up with yourself. Whatever it is, as long as it's contents would be ok after being run through JSON.stringify
(read: text files, not images or binary files), it will work just great with the source loader.
npm install source-loader -S
Just load it up in your webpack config like this:
module.exports = {
module: {
loaders: [
{ test: /\.foo$/, loader: 'source' }
]
}
}
Then you can require it up in your main entry:
const fooFile = require('testing.foo')
console.log(fooFile) // wow it's the contents!
- Details on the license can be found here
- Details on running tests and contributing can be found here