Skip to content

Lcfvs/flat-webpack-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flat-webpack-config

A flat configuration helper for webpack

Install

npm i -d flat-webpack-config

Usage

Initialize your module

mkdir project-name
cd project-name
npm init
npm i -d flat-webpack-config

Create a flat-webpack-config.json

{
  "bundles": {
    "app": {
      "anticore": "anticore"
    },
    "polyfills": {
      "fetch": "whatwg-fetch",
      "Promise": "es6-promise/dist/es6-promise.auto.min.js",
      "URL": "js-polyfills/url.js"
    }
  },
  "map": true,
  "output": "./assets/js",
  "spaces": 2
}

Create a webpack.config.js

'use strict';

module.exports = require('flat-webpack-config')(__dirname);

// or avoid the `flat-webpack-config.json` file by
module.exports = require('flat-webpack-config')(__dirname, {
  "bundles": {
    "app": {
      "anticore": "anticore"
    },
    "polyfills": {
      "fetch": "whatwg-fetch",
      "Promise": "es6-promise/dist/es6-promise.auto.min.js",
      "URL": "js-polyfills/url.js"
    }
  },
  "map": true,
  "output": "./assets/js",
  "spaces": 2
});

Run webpack

webpack

Tip: Target old browsers to load the polyfills

<script defer nomodule src="assets/js/polyfills.min.js"></script>
<script defer src="assets/js/app.min.js"></script>