Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/markmarijnissen/copy-loader
copy-loader for webpack: copies a file while maintaining directory structure and filename
https://github.com/markmarijnissen/copy-loader
Last synced: 4 months ago
JSON representation
copy-loader for webpack: copies a file while maintaining directory structure and filename
- Host: GitHub
- URL: https://github.com/markmarijnissen/copy-loader
- Owner: markmarijnissen
- Created: 2014-08-04T09:17:01.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-27T12:31:07.000Z (over 9 years ago)
- Last Synced: 2024-08-09T21:10:25.003Z (4 months ago)
- Language: JavaScript
- Size: 148 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED
Just use `file-loader`: `file?name=[path][name].[ext]&context=./src`.
Or, to keep a pretty syntax, add this to your `webpack.config.js`:
```javascript
resolveLoader: {
alias: {
'copy': 'file-loader?name=[path][name].[ext]&context=./src',
}
},
```So you can just do
```javascript
require("copy!somedir/myfile.html");
```and `src/somedir/myfile.html` will get copied to `/somedir/myfile.html`.
# copy loader for webpack
## Usage
``` javascript
// in /src/images/index.jsvar url = require("copy!./file.png");
// copies file.png to /output/images/file.png
// url = "/images/file.png"
```copy-loader copies a file from source to your output path without changing directory structure or filename. This is unlike the file-loader, which hashes the file and forgets the directory structure.
The directory structure is copied from the **root directory**, which is determined as follows:
1. From the query-string: e.g. `require("copy?src!./file.png")`
2. From `copyContext` in webpack.config.js
3. From `context` in webpack.config.js (defaults to `process.cwd()`, the current working directory)**Note:** You don't have to specify the full **path** - the directory name itself is sufficient.
## License
MIT (http://www.opensource.org/licenses/mit-license.php)