Lithe
Welcome Getting started Routing Build Signals and binding Web component Templates View transitions Fetcher Multiple languages github-circle-black-transparent GitHub github-circle-black-transparent Example app

Build

Build app with bundles optimized based on routes

Build app

No need for webpack or other bundlers. ESbuild is packed in and pre configured. Builds are also optimized based on route entry points.
  • Minification
  • Sourcemaps
  • Dev server
  • live relaoding
  • File copying
  • ENV vars
  • NODE_ENV=production will minify the code and NOT run the dev server
  • NODE_ENV=other value will run the dev server
  • You can override the default behavior
import build from '@thewebformula/lithe/build';

/**
* Basic
* If using 'app/' as root folder then no config needed
*/
build();


/**
* Full config options
*/
build({
  // App javascript file : Default 'app/app.js'
  entryPoint: 'app/app.js',

  /**
   * App styles file
   * If you add a path, the file will be bundled and output as a single .css file
   * Default: undefined
   */
  entryPointCSS: 'app/app.css',

  // index.html file : Default 'index.html'
  indexHTML: 'app/index.html',

  // folder that contains 'app.js' : Default 'dist/'
  outdir: 'dist/',

  /**
  * Minify code
  * Set to 'true' when 'NODE_ENV=production'
  *   otherwise it defaults to 'false'
  */
  minify: true,

  /**
  * Create source maps
  * Set to 'false' when 'NODE_ENV=production'
  *   otherwise it defaults to 'true'
  */
  sourcemap: false,

  /**
  * Run dev server
  * Set to 'false' when 'NODE_ENV=production'
  * otherwise it defaults to 'true'
  */
  devServer: true,

  /**
  * Livereload
  * Simply use watch to enable 'node --watch build.js'
  * Set to 'false' when 'NODE_ENV=production'
  * otherwise it defaults to 'true'
  */
  devServerLiveReload: true,
  
  devServerPort: 3000,
  

  /**
  * devWarnings
  * Enable console warning
  * only html sanitization currently
  * defaults to 'false'
  */
  devWarnings: false,

  /**
  * securityLevel
  * Set security level warnings for html
  * Default: 1
  */
  securityLevel: 1,

  // supports regex's with wildcards (*, **)
  copy: [
    {
      from: 'app/image.jpg',
      to: 'dist/'
    },
    {
      from: 'app/routes/**/(?!page)*.html',
      to: 'dist/routes'
    }
  ],

  // inject env vars to build
  define: {
    'process.env.SOME_VAR': process.env.SOME_VAR
  },

  // callback before bundle
  onStart: () => {},

  // callback after bundle
  onEnd: () => {}
});
          
menu