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 🙏

© 2026 – Pkg Stats / Ryan Hefner

als-mix

v1.1.11

Published

object for concatinating and compiling js and css files

Readme

als-mix

About

als-mix is the class that containes instruments for compiling few js or css files to one. The compiling process containes:

  1. Concatenating source files to one file
  2. Including the concatenated js code inside (function{code})() - the code not available from console
  3. Compiling the js code with Babel to es5
  4. Minifying the code as option

The main idea took from Laravel-mix with some differences. One of the main differences is that the source codes inside mixed js files are in the same scope and not inside separated functions. Acording to that, on one hand, you won't be able to use same variables and function names. But on the other hand, it will allow integration between different files inside one mixed file. Another difference, is about using cdn or online files as part of mix.


--

Install

npm i als-mix


--

Step 1: Define the mix

You need to define the mix object and mix files before use.

Mix is a class and it's constructor gets three parameters:

  1. jsPath - the output folder for JavaScript files
  2. cssPath - the output folder for css files
  3. downloads - the output folder for downloaded files

The syntax: new Mix(jsPath,cssPath,downloads)

Here the example code:

// ./resources/mix.js
const Mix = require('als-mix')
const path = require('path')

let jsPath = path.join(__dirname,'..','public','js')
let cssPath = path.join(__dirname,'..','public','css')
let downloads = path.join(__dirname,'downloads')
let mix = new Mix(jsPath,cssPath,downloads)

--

Step 2: Define the mix files

You can define how many mix files you want.

To define each file insert fileName:[files] to mix.js or mix.css. Here how it looks like:

{
    mixFileName:[
        pathToFile,
        link,
        PathToFolder
    ]
}

mixFileName - is the name of mix file will be created in mixFolder you defined before. Dont write extension to mix file name.

Each file inside array can be:

  1. Path to file - for example: path.join(__dirname,'someFolder','someFile.js')
  2. Path to folder - regular path as path to file. But in this case, all css or js files in the folder's path will be included in the mix.
  3. Link or cdn - direct link to js or css file. The file has to be downloaded before (with cli command - further)

Here the example:

// ./resources/mix.js

mix.js = {
    mainMix: [
        path.join(__dirname,'..','folder'),
        path.join(__dirname,'..','resources','some.js'),
        'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js'
    ],
    mainMix2: {
        ...
    }
}

mix.css = {
    mainMix: [
        path.join(__dirname,'..','folder'),
        path.join(__dirname,'..','resources','some.css'),
        'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css'
    ]
}

--

Step 3: run and use cli

Run mix.cli() and you will be able to use the folowing command lines commands.

  1. node mix download - downloading files from all links in mixes to download path (defined on constructor)
    • The command runs mix.download() method
  2. node mix mix - compiling and build the mix files in jsPath and cssPath
    • The command runs mix.mix() method
  3. node mix watch - wathcing for changes in source files and compiling the mix
    • The command runs mix.watch() method
  4. node mix minify - minifying the mix files
    • The command runs mix.minify() method

--

Full Code example

// ./resources/mix.js
const Mix = require('als-mix')
const path = require('path')

let jsPath = path.join(__dirname,'..','public','js')
let cssPath = path.join(__dirname,'..','public','css')
let downloads = path.join(__dirname,'downloads')
let mix = new Mix(jsPath,cssPath,downloads)


mix.js = {
    mainMix: [
        path.join(__dirname,'..','folder'),
        path.join(__dirname,'..','resources','some.js'),
        'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js'
    ]
}

mix.css = {
    mainMix: [
        path.join(__dirname,'..','folder'),
        path.join(__dirname,'..','resources','some.css'),
        'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css'
    ]
}

mix.cli()

In console inside ./resource folder

> node mix download
> node mix mix
> node mix watch
> node mix minify

Plugins to Babel

als-mix using Babel to convert the code to es5. In some cases, you will get messages to install some plugins to Babel.

I meet demand to plugin-proposal-class-properties in case of static methods inside class. In this case, install the plugin:

npm install --save-dev @babel/plugin-proposal-class-properties

Create file babel.config.json in project root folder with folowing:

{
    "plugins": ["@babel/plugin-proposal-class-properties"]
}