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

@pixel-engine/cli

v1.0.1

Published

Minimalist build tool inspired by create-react-app and next.js

Downloads

2

Readme

@pixel-engine/cli

Minimalist build tool inspired by create-react-app and next.js

Usage

Setup

Install

npm install @pixel-engine/cli --dev

And add scripts to your package.json like this

{
  "scripts": {
    "dev": "pixel",
    "build": "pixel build",
    "start": "pixel start"
  }
}

After that create your entry file (default ./src/main.js) and your up and running.

// ./src/main.js

class Game {
  ...
}

document.addEventListener('DOMContentLoaded', () => {
  const game = new Game()
}, false)

Static resources

Static resources are added in your assets directory (default ./res) you then request the resources as you normally would, eg.

const loadMap = () =>
  fetch('/res/map.json')
    .then(res => res.json())
    .then(data => new TileMap(data))

const loadImage = () =>
  new Promise((res, rej) => {
    const img = new Image()
    img.onload = () => res(img)
    img.onerror = err => rej(err)
    img.src = '/res/myimage.png'
  })

Configuration

If the default folder structure don't work with your project, then you can configure some basic options in two ways.

Using a pixel.config.js file:

module.exports = {
  main: './lib/index.js',
  assets: './assets',
}

Using cli options (inspect each command using the --help, -h flag):

npx pixel dev --main ./lib/index.js -p 9090

Options provided via cli arguments have higher precedence than options provided in the pixel.config.js file

Options

| pixel.config.js property | CLI argument | Type | Default | Description | | :------------------------- | :----------- | :------------ | :------------ | :-------------------------------------------------------- | | port | port, -p | Number | 1337 | Port number to run server at (webpack-serve option) | | host | hostname, -H | String | localhost | Host name to run the server at (webpack-serve option) | | main | main, -m | String | ./src/main.js | Entry file (webpack option) | | assets | assets, -a | String | ./res | Assets directory (copy-webpack-plugin option) | | template | template, -t | String | ./index.html | HTML template to use (html-webpack-plugin option) | | dist | dist, -d | String | ./dist | Output directory when building (webpack option) | | plugins | | Array | [] | List of plugins (not used atm) | | webpack | | Function | null | Function that can be used to extend webpack configuration |

Override webpack functionality

You can extend the webpack configuration by using the pixel.config.js file

// pixel.config.js
const webpack = require('webpack')

module.exports = {
  /**
   * @param {Object} webpackConfig The webpack config object
   * @param {String} dir           Working dir
   * @param {Boolean} dev          Development or production mode
   * @param {Object} config        Configuration object as provided by
   *                               default options => pixel.config.js => cli args
   * @param {Object} defaultLoader Object with defaultLoaders
   */
  webpack: (webpackConfig, { dir, dev, config, defaultLoaders }) => {
    // Add the decorators plugin
    defaultLoaders.babel.options.plugins.push('@babel/plugin-proposal-decorators')

    if (!dev) {
      // Add a top banner to your minifed code
      webpackConfig.plugins.push(new webpack.BannerPlugin({
        banner: 'This is a minifed build of: ' +
          'https://github.com/you/your-awesome-oss-game-code'
      }))
    }

    return webpackConfig
  }
}