@sbovyrin/webpack-mini

Minimal webpack config that is easy extending when it's necessary

Usage no npm install needed!

<script type="module">
  import sbovyrinWebpackMini from 'https://cdn.skypack.dev/@sbovyrin/webpack-mini';
</script>

README

webpack-mini

NPM npm GitHub issues npm (scoped)

Read Changelog before updating!

Minimal webpack config that is easy extending when it's necessary.

By default:

  • input file index.js must be located in src directory
  • html-template file must be located in project root
  • output files are located in dist directory

Quick start

  1. Create main js file in src directory: /src/index.js
  2. Create index.html template in your project root: /index.html
  3. Create webpack.config.js file in your project root
    • add next code to the file:
      const { defaultConfig } = require('@sbovyrin/webpack-mini');
      
      module.exports = defaultConfig();
      
  4. Optionally install webpack-dev-server: npm i --save-dev webpack-dev-server
  5. Start development server: npx webpack --watch --env.dev
    • or: npx webpack-dev-server --env.dev
  6. Build the project for production: npx webpack --env.prod
    • output files are located in /dist directory

Features

  • Ready to work out of the box
  • Easy to customize
  • Output separate files
    • app.js (your application)
    • vendor.js (app's dependencies)
    • runtime.js (wepback runtime)
    • styles.css (app's CSS)
  • Production files are optimized (including tree-shaking)
  • Hot server reload for development
  • Lightweight and low resource consumer

Customize

Change entry configuration

  • Create webpack.config.js file
    const { defaultConfig } = require('@sbovyrin/webpack-mini');
    
    module.exports = defaultConfig();
    
  • Create your customized config function
    // here 'env' has value passed to --env (i.e '--env.prod' in script command)
    function customizeConfig(env) {
      return {
        entry: 'mysource/app.js'
      }
    }
    
    module.exports = defaultConfig(customizeConfig);
    
  • Now your entry point is mysource/app.js

Using React.js

Comming soon...