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

generator-h5package

v4.2.0-alpha.2

Published

A Yeoman generator to generate html5 projects base on webpack

Downloads

125

Readme

generator-h5package

Translations: 简体中文

Note: webpack 4.0 Release. Convention over Configuration!!!

[email protected] supports webpack v3.

[email protected] supports webpack v4.

generator-h5package is a Yeoman plugin that uses Webpack+ Native Js to make starting up Web projects simple, quick and easy, the same as generator-phaser-h5

WHY

gulp is a toolkit for automating painful or time-consuming tasks in your development workflow, including watch, uglify Js, optimize Css, etc.

webpack is a static module bundler for modern JavaScript applications, do pretty much the same job as gulp. Also, use webpack stream to run webpack as a stream to conveniently integrate with gulp.

In browserify, you use gulp/grunt and a long list of transforms and plugins to get the job done. webpack offers enough power out of the box that you typically don’t need Grunt or Gulp at all.

HOW

Install


Note: Install Node.js First

  • Get Yeoman and generator-h5package via npm.

    npm install --global yo                    # Install Yeoman if you don't have it yet.
    npm install --global generator-h5package   # Install generator-h5package

Usage


  1. Create a directory to keep your project contents and go into it.

    mkdir myproject
    cd myproject
  2. Create your new project.

    yo h5package
  3. Launch it!

    npm run serve    # Launches the server and opens the page for live development.
    npm run build    # Prepare the h5 release for distribution.

The release in dist/

Directory Structure


In development, run npm run start:

    .
    ├── dist
    ├── src
    │   ├── index.html
    │   └── assets
    │       ├── img
    │       ├── media         # video audio resources
    │       ├── css
    │       │   ├── css.css
    │       │   └── sass.scss
    │       └── js
    │           ├── entities  
    │           └── main.js
    │   
    ├── node_modules
    ├── LICENSE
    ├── README.md
    ├── package.json
    ├── webpack.common.js      # "common" configuration
    ├── webpack.dev.js         # "development"
    └── webpack.prod.js        # "production"

In production, run npm run build:

   dist
    ├── assets
    │   ├── img
    │   ├── fonts
    │   ├── media
    │   ├── css
    │   │   └── main.[chunkhash].min.css
    │   └── js
    │       └── main.[chunkhash].min.js
    ├── favicon.ico
    └── index.html

Plugins


npm manages plugins.

devDependencies are for the development-related scripts, e.g. unit testing, packaging scripts, documentation generation, etc.

dependencies are required for production use, and assumed required for dev as well.

devDependencies:

Note: npm install --save-dev

dependencies:

Note: npm install

others:

Note: Read Documentation For a Getting started guide, Usage , API docs, etc. check out or docs!

Use the following ways Sometime:

  • Local In webpack.common.js Split your code into vendor.js and main.js:

    • remove CommonsChunkPlugin, add optimization.splitChunks and optimization.runtimeChunk
  • Use require(file) or import "module-name" in main.js

  • Cdn jsDelivr, cdnjs, bootcdn

Production


webpack.common.js (Don't repeat yourself - DRY)

"common" configuration

  • entry
  • ouput
  • module(babel-loader, css-loader, sass-loader, MiniCssExtractPlugin.loader, url-loader, postcss-loader)

webpack.dev.js (development)

"development" configuration

webpack.prod.js (production)

"production" configuration

  • optimization.minimizer(OptimizeCssAssetsPlugin, UglifyJsPlugin, etc.)
  • devtool:source-map Omit the devtool option more options

WHAT

Versions

1.x.x Inital Publish

  • 1.2.x Add uglifyjs-webpack-plugin
  • 1.3.x Add CommonsChunkPlugin
  • 1.4.x Add url-loader

2.x.x Separate webpack configurations for each environment.

  • 2.0.x Add webpack-merge
  • 2.1.x Add Doc Translations
  • 2.2.x Reset devtool

3.x.x Refactor Generator , Fix tests

  • 3.1.x Output Using [chunkhash]

4.x.x Refactor Generator for webpack 4

  • 4.0.x For webpack 4
  • 4.1.x Add postcss-loader for autoprefixer

Reference

gulp & webpack整合,鱼与熊掌我都要!

gulp与webpack的区别

前端开发利器 webpack

webpack 与RequireJS、browserify

webpack 从入门到工程实践

License

MIT License