Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@ayang4114/load_assets
Advanced tools
Readme
A command that generates a JavaScript file which contains an object that maps to loaded assets from a directory, including static images files, using require(...). This was built to support writing many imports/require statements for bundlers that load static assets/resources like webpack.
npm install -g @ayang4114/load_assets
On the command line, execute the following command
load_assets <directory_of_assets>
Any arguments passed without a flag is treated as an argument for the --input
flag, i.e. it treated as the input directory.
Flag | Description | Default |
---|---|---|
--input | The path to the directory to be converted into an asset file. | None |
--output | The output path name of the converted asset file | assets.js or assets.ts |
--targetLang | The target language of the output asset file: either 'ts' or 'js' | 'js' |
--indents | The number of indents in output file. | 2 |
--excludeExt | A space-separated sequence of all filetype extensions to ignore. | None |
--includeExt | A space-separated sequence of all filetype extensions to include. | None |
By default, all files with the extensions jpg, jpeg, png, and gif are included when traversing through the assets directory. These files can be ignored by adding the unwanted extensions as arguments in --excludeExt
.
Consider the following tree:
assets
├── moon.png
├── sun.png
├── nested_assets_1
│ ├── moon.jpg
│ └── sun.jpg
└── nested_assets_2
├── moon.jpg
├── nested_assets
│ ├── moon.jpg
│ └── sun.jpg
└── sun.jpg
Then, load_assets assets
will produce the following output in assets.js
:
module.asset = {
jpg: {
"nested_assets_1": {
"moon": require("./assets/nested_assets_1/moon.jpg"),
"sun": require("./assets/nested_assets_1/sun.jpg"),
},
"nested_assets_2": {
"moon": require("./assets/nested_assets_2/moon.jpg"),
"nested_assets": {
"moon": require("./assets/nested_assets_2/nested_assets/moon.jpg"),
"sun": require("./assets/nested_assets_2/nested_assets/sun.jpg"),
},
"sun": require("./assets/nested_assets_2/sun.jpg"),
},
},
png: {
"moon": require("./assets/moon.png"),
"sun": require("./assets/sun.png"),
}
};
Feel free to add issues or suggestions in the repository.
You can also make PRs:
FAQs
Generates a JavaScript file that loads all files via 'require' in a given directory. This is stored as an exported object.
The npm package @ayang4114/load_assets receives a total of 5 weekly downloads. As such, @ayang4114/load_assets popularity was classified as not popular.
We found that @ayang4114/load_assets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.