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

webpack-mpa-next

v4.0.0

Published

Multi page app setup with webpack

Downloads

55

Readme

Travis CI Github Build Codacy Badge Codebeat Badge CodeFactor Badge DeepScan grade Analytics

Webpack-MPA-Next

Opinionated multiple page application setup with Webpack using SASS, PostCSS, ES2017, PNG & SVG Sprites and more.

This boilerplate is suitable for static web applications, WordPress websites, etc.

Visitor stats

GitHub stars GitHub forks GitHub watchers GitHub followers

Code stats

GitHub code size in bytes GitHub repo size GitHub language count GitHub top language GitHub last commit

Dependencies

In order to use this setup you need to have installed the following dependencies:

  1. Node - min v8.9.4 - LTS recommended
  2. NPM - min v5.6.0 or
  3. Yarn - min v1.3.2
  4. Bash terminal (Default on OSX/Linux, GitBash or similar on Windows)

Default setup

The default setup uses PHP files, but you can easily switch to a file format of your choice.

Also, you can always switch to another file/folder structure if the current one does not suit you.

Just keep in mind that the styles should be located in assets/styles and the scripts should be located in assets/scripts.

Zero config and fast installation

Navigate to your new project's folder and execute the following command:

npx webpack-mpa-next && npm i && npm start

This will install Webpack-MPA in your project folder and you will be able to start right away.

Download

You can download this setup directly and extract it.

or use NPM or Yarn to install it:

npm i webpack-mpa-next

or

yarn add webpack-mpa-next

Then navigate to the webpack-mpa-next folder and proceed with the rest of the instructions.

Global installation

It is possible to use the CLI tool included in Webpack MPA Next. In order to do this you must install Webpack MPA Next globally:

npm i webpack-mpa-next -g

or

yarn global add webpack-mpa-next

The wmpan binary is now available for you to use.

Go to your new project folder and execute

wmpa

Your new project is setup!

Install dependencies

yarn

or

npm i

Develop

yarn start

or

npm start

Build

yarn build

or

npm run build

Details

  1. PostCSS stylesheets pre and postprocessing

  2. PNG Sprite generating using Webpack SpriteSmith The default setup includes retina sprite support which means that you should provide a retina version of each png icon.

    If you do not wish to use the retina sprite, comment the @include retina-sprites($retina-groups); statement in main.scss file.

    In order to use the PNG sprite, you need to do so by adding the relevant icons in your markup:

    <i class="ico-home"></i>

    The class name corresponds to the name of the PNG file.

  3. Latest EcmaScript support

    • Usage of the latest features in EcmaScript
    • Using Babel to transpile to ES5
    • Minification of the bundled file
    • Source maps
  4. Automatic browser reload using BrowserSync

    • The setup assumes that you have a web server (MAMP, XAMPP, etc) installed.
    • If you wish to use a proxy in browsersync you can do it using the url CLI argument like this:
    yarn start --env url=http://your.app

    or

    npm start --env url=http://your.app

    If you do not have a web server installed, then the files can be served via the browser-sync built-in server. In order to use this you need to pass a new CLI argument server like this.

    yarn start --env server

    or

    npm start --env server
  5. SVG Sprite generating using spritesh

    All svg files located in assets/images/svg are merged into a single sprite.svg file in dist directory.

    This action is performed each time the start command is invoked.

    In order to use the SVG sprite you first need to include it in your markup. You can do so in several ways:

    • If you're using PHP files, include it in each of your PHP files: <?php include_once('assets/dist/sprite.svg'); ?>
    • If you're using HTML files, paste the content of the SVG sprite in each of your HTML files.
    • If you're using another templating method (posthtml include, handlebars, ejs, etc) you need to do so according to its documentation.

    It is preferred to include the SVG sprite right after your opening <body> tag

    In order to add an SVG icon in your markup, you can do so by using the SVG <use> tag:

    This action is performed each time the start command is invoked.

    <svg class="svg-home">
    	<use xlink:href="#svg-home"></use>
    </svg>
  6. All front-end assets are stored in an auto-generated dist folder.

Assets

The assets folder contains several folders:

  • images - contains several folders too:
    • favicon - contains all icons variations
    • sprite - contains png sprite's parts
    • svg - contains svg sprite's parts
    • temp - contains content images
  • scripts - contains the JS modules
  • styles - contains the raw stylesheets

Each start command regenerates the contents of the dist folder.

Supported Browsers

This setup uses Browserslist to target browsers.

The default list of supported browsers is listed in the package.json file:

{
	"browserslist": ["> 1%", "last 2 versions"]
}

This means that supported browsers vary based on current usage data and current browser versions.

In general, this setup supports the two most recent versions of all browsers.

Scripts

There are several scripts defined in the package.json file:

{
	"build": "webpack --mode=production",
	"start": "webpack --watch --mode=development",
	"html": "php index.php > index.html",
	"critical": "critical index.html > assets/dist/critical.css",
	"rm-html": "rm index.html",
	"pwa": "create-pwa --icon=\"./assets/images/favicon/icon.png\"",
	"prod": "yarn build && yarn html && yarn critical && yarn rm-html"
}

Here is a bit more about what each script does:

  1. build: Builds the production version of the javascript and css bundles, regenerates PNG and SVG sprites.
  2. start: Starts the development sequence, regenerates PNG and SVG sprites, opens your default browser and watches for changes.
  3. html: Converts your index.php file to index.html.
  4. critical: Using the index.html extracts the critical css and generates a critical.css file in the assets/dist folder which is then inlined in the index.php file.
  5. rm-html: Deletes the index.html file.
  6. pwa: Generates boilerplate files for a PWA. More info here.
  7. prod: Runs 1, 4, 5, 6. (In this exact order).

In order to use the ability to generate critical CSS you must have the php binary exposed in your bash terminal. More about PHP's commandline usage can be found here.

Public vs. private projects

This starter boilerplate is licensed under the MIT open source license and is publicly available.

If you intend to use it to create a private and closed source project, please make sure to delete the license field in the package.json file and add "private": true in the same file.

This will make sure that you don't accidentally use an open source license for your private/closed source project.

LICENSE

MIT