npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aurelia-resource-index

v1.1.0

Published

Generates index.js to recursively declare all resources within a folder as global

Downloads

5

Readme

aurelia-resource-index

Generates global resource index files for all components within a folder.

In a project generated with aurelia-cli, it is common to place all global components within a src/resources folder.

This module will generate index files (e.g. src/resources/index.js) that includes all resources with this folder, recursively descending into subfolders, creating individual index files in each folder. By default, ignores files and folders that being with '.' (period).

Can be configured to generate index files that are compatible with requirejs, systemjs or webpack.

Install

npm install aurelia-resource-index

Configure

If you create a gulp task for this module, it is recommended you configure the module using aurelia.json as shown here.

Add the following entry for use with requirejs or systemjs.

  "resourceIndexer": {
    "view": "html",
    "pal": false,
    "mode": "single",
    "fileExtension": ".ts",
    "verbose": 1,
    "source": ["src/resources/**/*.*"]
  },

The last source entry is used by the watch task.

Add the following entry for use with webpack.

  "resourceIndexer": {
    "view": "html",
    "pal": true
  },

aurelia.json resourceIndex config

  • view - The file extension used when looking for view source files that do not have an accompanying js/ts file. Defaults to html. As an example, if using pug as an html preprocessor format then set to pug.
  • pal (boolean) - If true then each module is declared within a PLATFORM.moduleName() call. Used with webpack.
  • mode - If value is single then will declare all global resources using a single call to globalResources. Otherwise each resource is added individually. Do not set to single if using with webpack.
  • fileExtension - The file extension to use for the generated files. Defaults to .js.
  • verbose (integer) - If 1 then logs to console every index file that is updated or created. If 2 logs files that are unchanged. Default 0 for no logging.
  • exclude (RegExp) - Exclude files and folders with names that match this pattern. Defaults to files and folders that begin with a period /^\./.
  • excludeFile (string) - The name of a file with a list of files to exclude at that folder level. Defaults to .resourceignore.

To exclude certain files and folders from being indexed, set an exclude RegExp, or list specific files to exclude in a .resourceignore file in the same folder as the file you wish to excluse. Do not include the file extension when using .resourceignore. Hint: you can put files that you are not using in a .unused or .deprecated folder.

Run as Gulp Task on resources folder

Add a gulp task to your aurelia_project/tasks folder.

Create the file ${PROJECT_ROOT}/aurelia_project/tasks/resource-indexer.ts (or .js) with the following code:

import * as gulp from 'gulp';
import * as project from '../aurelia.json';
import * as IndexGenerator from 'aurelia-resource-index';

function generateResourceIndexFiles(done) {
  let config = project.resourceIndexer;
  let generator = new IndexGenerator(config, project.paths.root, project.paths.resources);
  generator
    .run()
    .then(resp => {
      done();
    })
    .catch(err => {
      done(err);
    });
}

const run = gulp.series(generateResourceIndexFiles);

export { run as default };

Build (webpack only)

In aurelia_projects/tasks/build.ts

import resourceIndexer from './resource-indexer';

And add this to the task list:

export { config, resourceIndexer, buildWebpack, build as default };

Build (requirejs and systemjs only)

In aurelia_projects/tasks/build.ts

import resourceIndexer from './resource-indexer';

And add the resourceIndexer as a gulp task:

let build = gulp.series(
  readProjectConfiguration,
  resourceIndexer,
  gulp.parallel(transpile, processMarkup, processJson, processCSS, copyFiles),
  writeBundles
);

Watch (webpack only)

Please contribute.

Watch (requirejs and systemjs only)

In aurelia_projects/tasks/watch.ts

import resourceIndexer from './resource-indexer';

and add this entry to the watches array:

  { name: 'globalResource', callback: resourceIndexer, source: project.resourceIndexer.source }

main.ts

In your main.js or main.ts file add the following. For Webpack, wrap resources with PLATFORM.moduleName('resources').

// Load the generated index.js
aurelia.use.feature('resources');

Developer

Build

Test

npm test