hey-cli
webpack脚手架,hot-dev-server,build
Last updated 2 days ago by vvpvvp .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hey-cli 
SYNC missed versions from official npm registry.

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
  "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

Current Tags

  • 2.5.6                                ...           latest (2 days ago)

87 Versions

  • 2.5.6                                ...           2 days ago
  • 2.5.5                                ...           2 days ago
  • 2.5.4                                ...           2 days ago
  • 2.5.3                                ...           2 days ago
  • 2.5.2                                ...           4 days ago
  • 2.5.1                                ...           5 days ago
  • 2.5.0                                ...           5 days ago
  • 2.4.1                                ...           5 days ago
  • 2.3.0                                ...           12 days ago
  • 2.2.0                                ...           a month ago
  • 2.1.0                                ...           a month ago
  • 2.0.0                                ...           a month ago
  • 1.14.1                                ...           a month ago
  • 1.14.0                                ...           a month ago
  • 1.13.2                                ...           3 months ago
  • 1.13.1                                ...           3 months ago
  • 1.13.0                                ...           3 months ago
  • 1.12.2                                ...           4 months ago
  • 1.12.1                                ...           5 months ago
  • 1.12.0                                ...           5 months ago
  • 1.11.1                                ...           5 months ago
  • 1.9.0                                ...           6 months ago
  • 1.8.0                                ...           7 months ago
  • 1.7.4                                ...           7 months ago
  • 1.7.3                                ...           7 months ago
  • 1.7.2                                ...           7 months ago
  • 1.7.1                                ...           7 months ago
  • 1.7.0                                ...           7 months ago
  • 1.6.0                                ...           8 months ago
  • 1.5.0                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.4                                ...           a year ago
  • 1.2.3                                ...           a year ago
  • 1.2.2                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.25                                ...           a year ago
  • 1.0.24                                ...           a year ago
  • 1.0.23                                ...           a year ago
  • 1.0.22                                ...           a year ago
  • 1.0.20                                ...           2 years ago
  • 1.0.19                                ...           2 years ago
  • 1.0.17                                ...           2 years ago
  • 1.0.16                                ...           2 years ago
  • 1.0.15                                ...           2 years ago
  • 1.0.14                                ...           2 years ago
  • 1.0.13                                ...           2 years ago
  • 1.0.12                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.26                                ...           2 years ago
  • 0.0.25                                ...           2 years ago
  • 0.0.24                                ...           2 years ago
  • 0.0.23                                ...           2 years ago
  • 0.0.22                                ...           2 years ago
  • 0.0.21                                ...           2 years ago
  • 0.0.20                                ...           2 years ago
  • 0.0.19                                ...           2 years ago
  • 0.0.18                                ...           2 years ago
  • 0.0.17                                ...           2 years ago
  • 0.0.16                                ...           2 years ago
  • 0.0.14                                ...           2 years ago
  • 0.0.13                                ...           2 years ago
  • 0.0.11                                ...           2 years ago
  • 0.0.10                                ...           2 years ago
  • 0.0.9                                ...           2 years ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 2
This Week 187
This Month 325
Last Day 3
Last Week 32
Last Month 518
Dependencies (72)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |