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 🙏

© 2025 – Pkg Stats / Ryan Hefner

webpack-turnkey

v1.9.4

Published

Webpack configuration project - turnkey

Readme

Webpack configuration - turnkey

Move to package Webpack turnkey

How it works

Scripts which are in assets/pages folder are bundled into public/js as default.

Install

  • npm i -S webpack-turnkey
  • Update package.json

Usage

There are two ways to use it :

  • With npx
    npx webpack-turnkey
  • With package scripts
    {
        "name": "...",
        "version": "...",
        "scripts": {
            "dev": "webpack-turnkey",
            "prod": "NODE_ENV=prod webpack-turnkey"
        },
    }

By default the command add -d option, when environment variable NODE_ENV is equal to prod it will pass the -p option.

Work with WEBPACK_TURNKEY_ENTRY environment variable

The value of this variable is, by default, a relative path, from assets/pages/. It can be a file or a folder.

Examples:

  • WEBPACK_TURNKEY_ENTRY="game" npx webpack-turnkey
    • => assets/pages/game/*
  • WEBPACK_TURNKEY_ENTRY="homepage.jsx" npx webpack-turnkey
    • => assets/pages/homepage.jsx
  • WEBPACK_TURNKEY_ENTRY="profile/index.jsx" npx webpack-turnkey
    • => assets/pages/profile/index.jsx

Shortcut to argument(s) with no options related exists too :

Examples:

  • npx webpack-turnkey game
    • => assets/pages/game/*
  • npx webpack-turnkey homepage.jsx
    • => assets/pages/homepage.jsx
  • npx webpack-turnkey profile/index.jsx
    • => assets/pages/profile/index.jsx
  • npx webpack-turnkey game homepage.jsx profile/index.jsx
    • => assets/pages/game/*
    • => assets/pages/homepage.jsx
    • => assets/pages/profile/index.jsx

Override directories

You can override directory with environment variable:

  • WEBPACK_TURNKEY_PROJECT_DIR:
    • absolute path to the project directory (process.cwd)
    • (ex: '/home/project')
  • WEBPACK_TURNKEY_ASSET_SUFFIX:
    • relative path to PROJECT_DIR (process.cwd)
    • (ex: 'assets')
  • WEBPACK_TURNKEY_ASSET_DIR:
    • absolute path to entries of type asset directory
    • (ex: '/home/project/assets')
  • WEBPACK_TURNKEY_PAGE_SUFFIX:
    • relative path to ASSET_DIR
    • (ex: 'pages')
  • WEBPACK_TURNKEY_PAGE_DIR:
    • absolute path to entries of type page directory
    • (ex: '/home/project/assets/pages')
  • WEBPACK_TURNKEY_PUBLIC_SUFFIX:
    • relative path to PROJECT_DIR (process.cwd)
    • (ex: 'public')
  • WEBPACK_TURNKEY_PUBLIC_DIR:
    • absolute path to public folder
    • (ex: '/home/project/public')
  • WEBPACK_TURNKEY_OUTPUT_SUFFIX:
    • folder name between public directory and page path
    • (ex: 'js')
  • WEBPACK_TURNKEY_OUTPUT_DIR:
    • absolute path to output directory
    • (ex: '/home/project/public/js')

Options

Sourcemap

An option --sourcemap use it with : npx webpack-turnkey --sourcemap It will set options to true for styles loaders

ESLint

An option --eslint use it with : npx webpack-turnkey --eslint It will add .eslintrc.js at the root of your project if not exists and compile with it.

Bundled

An option --bundled use it with : npx webpack-turnkey --bundled It will set the project directory to the current working directory

Usefull for Symfony <= 3 projects & assetic
cd src/MyBundle/Ressources && npx webpack-turnkey --bundled
It will compile files in MyBundle/Resources/assets/pages to MyBundle/Resources/public/js

Watch and other options

Other options like --watch are passed to webpack command

Proposed configuration

Loaders

Files loaded and extensions permitted :

For codes files :

  • .html
  • .js / .jsx / .mjs
  • .css
  • .sass / .scss

For images files :

  • .jpg / .jpeg
  • .png
  • .gif

For fonts files :

  • .svg
  • .woff / .woff2
  • .ttf / .otf
  • .eot

Aliases

You can call specifics folders with aliases, there are :

  • @actions => ASSET_DIR/actions
  • @capsules => ASSET_DIR/capsules
  • @components => ASSET_DIR/components
  • @connecters => ASSET_DIR/connecters
  • @constants => ASSET_DIR/constants
  • @containers => ASSET_DIR/containers
  • @fonts => ASSET_DIR/fonts
  • @images => ASSET_DIR/images
  • @managers => ASSET_DIR/managers
  • @middlewares => ASSET_DIR/middlewares
  • @models => ASSET_DIR/models
  • @pages => ASSET_DIR/pages
  • @reducers => ASSET_DIR/reducers
  • @sounds => ASSET_DIR/sounds
  • @stylesheets => ASSET_DIR/stylesheets
  • @utils => ASSET_DIR/utils
  • @videos => ASSET_DIR/videos

Customization

Create your own webpack.config.js at the root of your project and run webpack command.

'use strict';

const wpt = require('webpack-turnkey');

module.exports = Object.assign({}, wpt.config);

If you run webpack-turnkey command with a webpack-turnkey.config.js file, it will merge default config with your config.

module.exports = {
    alias: {...},
    rules: [{...}, {...}, ...],
    extensions: [...]
};

Generation

npx webpack-turnkey --generate <format>

To generate template for start coding, two format are available:

  • minimal:
    • Create asset and public folders
    • Add folders in ASSET_DIR
      • components
      • stylesheets
  • starter:
    • Create asset and public folders
    • Add folders in ASSET_DIR
      • components
      • constants
      • managers
      • models
      • stylesheets
      • utils
    • Install modules
      • @fortawesome/fontawesome
      • @fortawesome/fontawesome-free
      • @fortawesome/react-fontawesome
      • bootstrap
      • classnames
      • jquery
      • popper.js
      • react
      • react-dom
      • toast
    • Create files
      • components/super.jsx : An improved component (can be deleted if not used)
      • middlewares/event.js : Contains an prevent middleware
      • pages/style.js : Instanciate boostrap, fontawesome, jquery, toastr
      • stylesheets/* : Import style with helpers

Requirements

Webpack >= 3.10

Thanks

Thanks BP