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

ng-md-theme-loader

v1.0.1

Published

Adds AngularJS Material custome theme CSS templates in the Webpack bundle.

Downloads

63

Readme

AngularJS Material Custom Theme loader for webpack

Adds your AngularJS Material custom theme css into your webpack Javascript Bundle.

ng-md-theme-loader does not minify or process your css at all, and instead uses standard loaders such as sass-loader. This gives you enough flexibility to pick and choose your loaders.

Install

npm install ng-md-theme-loader --save-dev

Usage

Documentation: Using loaders

Documentation: ng-material's theme implementation

ng-md-theme-loader creates a JS module that registers MD CSS template with $mdThemingProvider e.g.

require('!ng-md-theme-loader!file.theme.css');

generates the javascript:

angular.module('ngMaterial').run(['$mdThemingProvider', function(c) { c.registerStyles('content of the ?.theme.css file') }]);

module

By default ng-md-theme-loader adds a run method to the global 'ngMaterial' module which should be explicitly required by your app for using Angular Material. You can override this by setting the module parameter, e.g.

require('!ng-md-theme-loader?module=myApp!file.theme.css');

generates the javascript:

angular.module('myApp').run(['$mdThemingProvider', function(c) { c.registerStyles('content of the ?.theme.css file') }]);

NOTE: specified module should be preliminary defined in your application

Parameter Interpolation

module parameter is interpolated using Webpack's standard interpolation rules.

Using with npm requires

This module relies on angular being available on window object. However, in cases angular is connected from node_modules via require('angular'), option to force this module to get the angular should be used:

require('!ng-md-theme-loader?requireAngular!file.theme.css');

generates the javascript:

var angular = require('angular');
angular.module('ngMaterial').run(['$mdThemingProvider', function(c) { c.registerStyles('content of the ?.theme.css file') }]);

Webpack Config

It's recommended to adjust your webpack.config so ng-md-theme-loader is applied automatically on all files ending with e.g. .theme.css. For Webpack 1 this would be something like:

module.exports = {
  module: {
    loaders: [
      {
        test: /\.theme\.css$/,
        loader: 'ng-md-theme'
      },
      {
        test: /\.theme\.scss$/,
        loader: 'ng-md-theme!sass'
      }
      // other loaders...
    ]
  }
};

For Webpack 2 this would be something like:

module.exports = {
  module: {
    rules: [
      {
        test: /\.theme\.css$/,
        use: [
          { loader: 'ng-md-theme-loader'},
        ]
      },
      {
        test: /\.theme\.scss$/,
        use: [
          { loader: 'ng-md-theme-loader'},
          { loader: 'sass-loader' }
        ]
      }
      // other loaders...
    ]
  }
};

Make sure you already have sass-loader installed. Then you only need to write: require('file.theme.css').

License

MIT (http://www.opensource.org/licenses/mit-license.php)