https://github.com/assertible/move-file-loader
A Webpack loader to move files from one location to another
https://github.com/assertible/move-file-loader
javascript javascript-tools webpack webpack-loader
Last synced: 4 months ago
JSON representation
A Webpack loader to move files from one location to another
- Host: GitHub
- URL: https://github.com/assertible/move-file-loader
- Owner: assertible
- License: mit
- Created: 2017-05-21T00:55:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-12T18:47:11.000Z (over 7 years ago)
- Last Synced: 2025-08-23T04:33:58.777Z (4 months ago)
- Topics: javascript, javascript-tools, webpack, webpack-loader
- Language: JavaScript
- Homepage: https://assertible.com/blog/npm-package-move-file-loader-for-webpack
- Size: 23.4 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# move-file-loader for Webpack
> A Webpack loader to move files from one location to another and return the contents.
[](https://www.npmjs.com/package/move-file-loader)
This webpack loader allows you to output required or imported files to
a specific location, and return the contents of the file. Check out the
[blog post](https://assertible.com/blog/npm-package-move-file-loader-for-webpack)
for more examples.
## Install
```sh
$ npm i --save move-file-loader
```
## Usage
Add a loader to your Webpack configuration that describes how and
where to move the file. The contents of the file are returned from the
loader.
```js
module.exports = {
...your webpack config,
module: {
rules: [{
test: /.json/,
/**
* This will move .json files to the [path]/[name].json
* location after being processed by json-loader
*/
use: "move-file-loader?name=[path][name].json!json"
}]
},
...the rest of your webpack config
}
```
And import a JSON file:
```js
import stuff from 'file.json'
console.log(stuff); // Contents of the JSON file
```
## License
All of the code snippets in this repository are licensed under
MIT. [View the license](https://github.com/assertible/deployments/blob/master/LICENSE)
---
> [assertible.com](http://assertible.com) ·
> GitHub [@assertible](https://github.com/assertible) ·
> Twitter [@AssertibleApp](https://twitter.com/AssertibleApp)