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

hey-cli

v2.7.1

Published

webpack脚手架,hot-dev-server,build

Downloads

228

Readme

hey-cli

Webpack scaffolding, hot-dev-server, build.
Do not need to understand webpack, only need to know how to configure it to use, get rid of cumbersome duplication of webpack configuration.

中文文档

此处有中文文档

Advantage

  • Global installation, all development projects are supported, do not need to install and configure each project webpack.
  • Support ES6
  • Support Hot Module Replacement
  • Support Http Proxy
  • Default support vue2.0, support react
  • Support the global less parameter definition
  • Build UMD mode code
  • Only need to configure hey.conf.js configuration file

Installation

npm install -g hey-cli

# new version npm
sudo npm install -g hey-cli --unsafe-perm=true --allow-root

Configuration

Add the hey.conf.js configuration file in the project root directory.

module.exports = {
  "port": 9002, //Port
  "dist": 'dist', //the root of the build file
  "clean": true, //clean dist folder before build
  "timestamp": false, //the static folder generated by build with the static[timestamp] named folder
  "react": true, //support react project
  "openBrowser": true, // open browser auto
  "stat": true, // Whether to generate stat.json
  "webpack": { //webpack related configuration
    "console": false, //package compression whether to retain the console, the default is false
    "publicPath": "/", //public path
    "compress": true / false, // default value depends on build or dev, or you can set compress js when build.
    "output": {
      // Output what documents, mainly html,
      // Default setting will load the same js file as the html file name for the entrance. 
      // Support for defining common packages.
      "./*.html": {
        // Load js file by default, and html automatically references. 
        //If not configured, the same js file as the html file name is automatically
        "entry":"./src/index.js"
      }
    },

    //define resolve, https://webpack.js.org/configuration/resolve/
    "alias": {
      components: './src/components/',
      // You can use import index from 'components/index'  => src/components/index
    },

    //define global, https://webpack.js.org/plugins/provide-plugin
    "global": {
      "Vue": "vue",
      "$": "jquery",
      "log": "./js/common/log",
      // use export default
      Utils: [path.resolve(__dirname, 'src/js/common/utils'), 'default'],
    },

    //define proxy, https://webpack.js.org/configuration/dev-server/#devserver-proxy
    "devServer": {
      "proxy": {
        "/api": {
          "target": "http://yoda:9000"
        }
      },
      historyApiFallback: true
    },
    //define externals, https://webpack.js.org/configuration/externals/
    "externals":{

    },

    //Define the global less parameter definition, you can use the globalVars parameter in any less
    globalVars: './static/css/var.less',
  },

  // The files that are not referenced are copied to the packaged folder when build
  "copy": [
    "./images/**/*",
    "./help/**/*",
    "./template/**/*"
  ]
};

Extended Configuration

You can expand and configure the following properties in the webpack configuration item in hey.conf.js:

  • plugins
  • module
  • node
  • externals
  • devServer

Specific use, please refer to webpack document.

Example

Load vue,vue-router

"hey": {
  "port": 9008,
  "timestamp": true,
  "dist": "gen",
  "webpack": {
    "publicPath": "/",
    "output": {
      "./*.html": {
        "entry":"./src/app"
      }
    },
    "global": {
      "Vue": "vue"
    },
    "devServer": {
      "historyApiFallback":true
    }
  }
}

External loading vue,vue-router

"hey": {
  "port": 9008,
  "timestamp": true,
  "dist": "gen",
  "webpack": {
    "publicPath": "/",
    "output": {
      "./*.html": {
        "entry":"src/app"
      }
    },
    "global": {
      "Vue": "vue"
    },
    "devServer": {
      "historyApiFallback":true
    },
    "externals": {
      "Vue": "window.Vue",
      "VueRouter": "window.VueRouter"
    }
  }
}

Common code to build UMD mode

Mainly used to build some of the common code, simple configuration can be used.
Because it is a public package packaged into UMD mode, do not use the import mode.

module.exports = {
  dist: "build",
  webpack: {
    umd: {
      entry: "./src/index.js",
      library: "Validator",
      filename: 'validator.js', //build generation /build/validator.js
      libraryExport: 'default'
    },
    externals: {
      "manba": "manba"  //The dependent package will not be packaged into the source code
    }
  }
};

Deploy

Start webpack server

hey dev
hey build

# use custom config file build project
hey build -f index.esm.js

Analyze

You can generate analyze.

hey dev -r
# or
hey dev --report

# after hey build
hey report
# or
hey report -p port -f dist/stat.json

analyze

Parameter

//Identification is a development environment, or a production environment
const debug = process.env.NODE_ENV == 'development'; //production

Generate Project

Generate project using template.

hey init <project-name>
# hey init test

The current template

  • Simple: Base ES6 project
  • HeyUI: HeyUI project
  • Vue: Base Vue project
  • React: Base React project
  • ElementUI: Element project
  • iViewUI: iViewUI project

For specific projects, please refer to hey-cli-template