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

laxar-loader

v2.1.1

Published

Webpack loader for LaxarJS artifacts

Downloads

122

Readme

laxar-loader Build Status

webpack loader for LaxarJS

Bundles and validates LaxarJS application artifacts as needed.

Example

You could use laxar-loader directly, but since it does not need a specific entry module, we pre-rolled the artifacts and debug-info entry points for you and placed them into this module. Import the entry points in your init.js:

import artifacts from 'laxar-loader/artifacts?flow=main&theme=rainbows-and-unicorns';
import debugInfo from 'laxar-loader/debug-info?flow=main&theme=rainbows-and-unicorns';
import { create } from 'laxar';

// const adapters = [ ... ];
// const configuration = { ... };
// ... later ...

create( adapters, artifacts, configuration )
  .tooling( debugInfo )
  .bootstrap();

Configuration

Place a laxar.config.js file into your project root directory. This is either the directory where your webpack.config.js is, or the directory configured with webpack's context option.

The laxar.config.js file should look like this:

module.exports = {
   paths: {
      flows: './path/to/flows', // default: './application/flows'
      themes: './path/to/themes', // default: './application/themes'
      pages: './path/to/pages', // default: './application/pages'
      layouts: './path/to/layouts', // default: './application/layouts'
      widgets: './path/to/widgets', // default: './application/widgets'
      controls: './path/to/controls', // default: './application/controls'
      'default-theme': './path/to/default.theme'
   }
};

If no laxar.config.js exists, the defaults (above) are used.

Query options (aka the stuff after the "?")

| Parameter | Description | | --------- | ----------- | | ?flow, ?flows[] | reference(s) to the flow(s) to bundle | | ?theme, ?themes[] | reference(s) to the theme(s) to bundle | | ?page, ?pages[] | reference(s) to the page(s) to bundle; can be omitted if pages are reachable from the flow | | ?layout, ?layouts[] | reference(s) to the layout(s) to bundle; can be omitted if layouts are referenced in bundled pages | | ?widget, ?widgets[] | reference(s) to the widget(s) to bundle; can be omitted if widgets are referenced in bundled pages | | ?control, ?controls[] | reference(s) to the control(s) to bundle; can be omitted if controls are referenced in bundled widgets |

Refer to the webpack documentation for details about the loader syntax.

The loaded artifacts listing can then be used to bootstrap LaxarJS.

Interaction with other loaders

When building the artifacts listing, the loader collects JSON, HTML and CSS files and generates require calls so they will be present in your webpack bundle. If no loaders are configured for the required files, laxar-loader will use the json-loader for JSON files, raw-loader for HTML and will write out the resource path for CSS files.

The debug-info bundle is wrapped with bundle-loader?lazy, exporting a function that can be called to asynchronously load debug information if necessary.

If you want to leverage the power of webpack to pre-process these artifacts, just add your loaders to the webpack configuration and they will be used to load the artifacts' assets. There are just a few rules your loaders should obey:

  • Template sources should be valid HTML strings after passing through your loaders.
  • Style sources should be URLs (file- or url-loader) or be loaded outside Laxar via the style-loader.

Example:

module.exports = {
   entry: { 'init': './init.js' },

   output: {
      path: path.resolve( __dirname, `./${publicPath}` ),
      publicPath,
      filename: '[name].bundle.js',
      chunkFilename: '[name].bundle.js'
   },

   module: {
      rules: [
         {
            test: /\.(css|gif|jpe?g|png|ttf|woff2?|svg|eot|otf)(\?.*)?$/,
            loader: 'file-loader',
            options: {
               name: 'assets/[name]-[sha1:hash:hex:6].[ext]'
            }
         },
         {
            test: /\.(gif|jpe?g|png|svg)$/,
            loader: 'img-loader?progressive=true'
         },
         {
            test: /\.css$/,
            loader: 'style-loader!css-loader'
         },
         {
            test: /\/default.theme\/.*\.scss$/,
            loader: 'sass-loader',
            options: require( 'laxar-uikit/themes/default.theme/sass-options' )
         },
         {
            test: /\/rainbows-and-unicorns\.theme\/.*\.scss$/,
            loader: 'sass-loader',
            options: require( './application/themes/rainbows-and-unicorns.theme/sass-options' )
         }
      ]
   }
};