Installations
npm install text-replace-file-loader
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
7.10.1
NPM Version
4.2.0
Score
67.1
Supply Chain
94.7
Quality
74.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
scottcrossen
Download Statistics
Total Downloads
851
Last Day
1
Last Week
1
Last Month
2
Last Year
73
GitHub Statistics
14 Commits
2 Watching
2 Branches
1 Contributors
Package Meta Information
Latest Version
0.1.0
Package Id
text-replace-file-loader@0.1.0
Size
4.25 kB
NPM Version
4.2.0
Node Version
7.10.1
Total Downloads
Cumulative downloads
Total Downloads
851
Last day
0%
1
Compared to previous day
Last week
0%
1
Compared to previous week
Last month
-60%
2
Compared to previous month
Last year
-15.1%
73
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Text Replace File Loader
A loader for webpack that imports all files in a given document, replacing the 'require' statements with their public path.
Install
1npm install --save-dev text-replace-file-loader
Usage
Use the loader either via your webpack config, CLI or inline.
Webpack Config (recommended)
webpack.config.js
1module.exports = { 2 module: { 3 rules: [ 4 { 5 test: /\.json$/, 6 use: ['json-loader', 'text-replace-file-loader?name=[name].[ext]'] 7 } 8 ] 9 } 10}
Example
Example
webpack.config.js
1module.exports = { 2 output: { 3 path: path.resolve(__dirname, 'dist'), 4 filename: 'something.js', 5 publicPath: '/', 6 }, 7 module: { 8 loaders: [ 9 { 10 test: /\.json$/, 11 // This will output both the json and all files the json requires on. 12 use: ['file-loader?name=[name].[ext]', 'text-replace-file-loader?name=[name].[ext]'] 13 } 14 ] 15 } 16}
In your application
1const myJson = require('./file.json'); // Can handle any type of file though.
Your Json: file.json
1{ 2 "key1": { 3 "key2": { 4 "key3": "require('assets/images/image1.png')" 5 }, 6 "key4": "require('assets/index.json')" 7 } 8}
Output
Directory listing
1something.js 2image1.png 3index.json 4file.json
Output Json: dist/file.json
1{ 2 "key1": { 3 "key2": { 4 "key3": "/image1.png" 5 }, 6 "key4": "/index.json" 7 } 8}
Note: If publicPath were 'myurl' then it would be 'myurl/image1.png' rather than '/image1.png'
Options & Config
This module has two different options:
- recursion: This sets the behavior when
require('.*')
statements are encountered. It can be one of three values. The default is 'emit'.- 'embed': This embeds imports into the file inline.
- 'emit': This creates a file in the bundle and replaces the import statement with the public path.
- 'none': This replaces the import statement with the best-guess at the module-name.
- emit: This determines whether the final document is emitted to the bundle or not. Takes on boolean true or false. The default is true.
Note that for file-emitting operations, this module clones its context and passes it on to file-loader
. Because of this, please reference file-loader
's
main page for information on
options and config for emitting files. You can pass these options to this loader when emitting files.
Contributors
Scott Leland Crossen
http://scottcrossen42.com
scottcrossen42@gmail.com
Special Thanks
Brady Parks, Sydney MacFarlane, John Hancock, Doug Patterson, Megan Parks, Madison Russell
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/13 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More