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

sprockets-loader

v0.5.1

Published

A JavaScript, Webpack-enabled Rails Sprockets port.

Downloads

24

Readme

sprockets-loader Build Status Version Status

A JavaScript, Webpack-enabled Rails Sprockets port.

Bring Sprockets into JavaScript's realm. Features include:

  • Parses Sprockets directives, require, require_tree and require_directory.
  • Uses the same logical path file location resolution as Rails Sprockets.
  • Reads your Gemfile.lock, enabling Gem usage, like jquery-ujs.

Installation

$ npm install sprockets-loader --save-dev

Usage

// Your webpack configuration
module.exports = {
  entry: {
    'application.js': './examples/application.js'
  },
  output: {
    path: 'public/assets',
    filename: '[name]'
  },
  module: {
    preLoaders: [
      {
        loader: 'sprockets-loader',
        query: {
          logicalPaths: [
            'examples'
          ]
        }
      }
    ]
  }
};

Tests

You can run tests with: npm test or npm run watch.

Stylesheets?

While sprockets-loader can handle stylesheets, it is suggested that you do not use it for them.

Everything in Webpack requires that the second and subsequent steps of the loader process produce JavaScript source. SASS, LESS, and CSS can be parsed in the first step, but are output with stylesheet Webpack loaders. That means, during development, you'll have to include your stylesheets as JavaScript – Highly weird, if you ask me.

If you insist on trying it, here's a small idea of how that would work:

// Your webpack configuration
module.exports = {
  entry: {
    'application.css.js': './examples/application.css'
  },
  // ...
};
<html>
  <head>
    <script type="text/javascript" src="application.css.js"></script>
  </head>
  <!-- ... -->
</html>

Extension

This repository uses the term compat to mean a base file type, such as .js. These compats can be found here. There are three components to create a complete compat:

  • extensions: Other file types that are compatible with the base file type.
  • loaders: Order-dependent loaders that are needed to interpret the base file compat, if encountered.
  • terminal: What the final file type should be, which can and in most cases will be different from the base file type.