0.39.2 • Published 7 months ago

@rubixibuc/build-scripts v0.39.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

build-scripts

Batteries included webpack + module federation build and linting scripts

Quick Start

  • create ./src/bootstrap.js entry file
  • add optional configuration
  • run directly
    npx @rubixibuc/build-scripts run
    or install globally
    npm i -g @rubixibuc/build-scripts
    build-scripts run

Usage

  • create ./src/bootstrap.js entry file
  • add optional configuration
  • add dependency to project
    npm i -D @rubixibuc/build-scripts
  • add start and build scripts to package.json
    {
      "scripts": {
        "start": "build-scripts run",
        "build": "build-scripts build"
      }
    }

CLI

  • build Outputs production build to ./dist folder
    build-scripts build
  • eslint Runs eslint against project files
    build-scripts eslint [-f, --fix] [-c, --cache] [-mw, --max-warnings <max-warnings>] <paths/globs>
  • prettier Runs prettier against project files
    build-scripts prettier [-f, --fix] <paths/globs>
  • run Runs dev server if specified, command line port overrides setting from config
    build-scripts run [-p, --port <port>]
  • stylelint Runs stylelint against project files
    build-scripts stylelint [-f, --fix] [-cs, --custom-syntax <custom-syntax>] [-mw, --max-warnings <max-warnings>] <paths/globs>

Configuration

  • example + defaults build-scripts.config.js configuration formats
    // importing from separate files is a recommended pattern
    module.exports = {
      // app meta
      background: "#fff",
      // copy all files inside public folder to output destination folder
      // undefined = autodetect (copy files if public folder exists)
      // false = disable public folder copy
      // true = force public folder copy
      copy: void 0,
      // module federation exposed paths
      exposes: {},
      // link tags [1]
      links: [],
      // favicons (all sizes generated)
      // undefined = "<included image>"
      logo: void 0,
      // meta tags [1]
      metas: [],
      // obfuscator options [2]
      // false = disabled
      // {} = options
      obfuscator: false,
      // import web polyfills
      // {} = custom polyfill configuration
      // false = no polyfills
      // undefined = include all polyfills
      polyfill: {
        // imports both "core-js/stable" and "regenerator-runtime/runtime"
        // import "@rubixibuc/build-scripts/polyfill/browser" to add manually
        // true = browser polyfill
        // false = no browser polyfill
        browser: true,
        // imports both "@webcomponents/webcomponentsjs" and "construct-style-sheets-polyfil"
        // import "@rubixibuc/build-scripts/polyfill/component" to add manually
        // true = component polyfill
        // false = no component polyfill
        component: true,
      },
      // webpack dev server port
      port: 8080,
      // import src/preboot.(tsx|ts|jsx|js) before async bootstrap
      // undefined = autodetect (import preboot.* file if it exists)
      // false = ignore preboot.* file
      // true = force import
      preboot: void 0,
      // module federation remotes
      remotes: {},
      // script tags [1]
      scripts: [],
      // module federation shared modules
      shared: {},
      // tailwindcss configuration [3]
      // tailwindcss utility classes are automatically prefixed with varName below
      // false = no tailwindcss
      // {} = tailwindcss configuration
      tailwindcss: false,
      // app meta
      themeColor: "#fff",
      // site title
      title: "My App",
      // module federation var name
      varName: "myapp",
    };
  • example .lintstagedrc.json
    {
      "*.js": "build-scripts eslint --cache --fix",
      "*.css": "build-scripts stylelint --fix",
      "*.{json,md}": "build-scripts prettier --fix"
    }

Javascript Variants

  • *.js
  • *.jsx
  • *.ts (transpiles, but doesn't do build time typechecking)
  • *.tsx (transpiles, but doesn't do build time typechecking)

Importing Assets

  • All asset types are supported according to the following rules
    // exp === "data:[...]"
    import exp from "./some-asset.png?data";
    // exp === "[...]/some-asset.1234.png?file"
    import exp from "./some-asset.png?file";
    // exp === "contents of file"
    import exp from "./some-asset.txt?source";
  • Specific rules for *.css imports
    // exp === new CSSStyleSheet()
    // https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet
    import exp from "./some-style.css";
    // exp === "processed css as string"
    import exp from "./some-style.css?string";
    // load style
    import "./some-style.css?style";
  • Additional rule for creating webp formatted images
    // exp === "[...]/some-image.1234.webp"
    import exp from "./some-image.png?file&as=webp";
0.37.2

9 months ago

0.37.1

9 months ago

0.37.0

9 months ago

0.38.0

9 months ago

0.39.1

9 months ago

0.39.0

9 months ago

0.39.2

7 months ago

0.36.0

1 year ago

0.35.25

2 years ago

0.32.8

2 years ago

0.32.7

2 years ago

0.32.6

2 years ago

0.32.5

2 years ago

0.32.4

2 years ago

0.32.3

2 years ago

0.32.2

2 years ago

0.32.1

2 years ago

0.32.9

2 years ago

0.32.0

2 years ago

0.33.3

2 years ago

0.33.2

2 years ago

0.33.1

2 years ago

0.33.0

2 years ago

0.35.22

2 years ago

0.35.23

2 years ago

0.35.20

2 years ago

0.35.21

2 years ago

0.35.24

2 years ago

0.35.11

2 years ago

0.35.12

2 years ago

0.35.10

2 years ago

0.34.2

2 years ago

0.34.1

2 years ago

0.34.0

2 years ago

0.30.3

2 years ago

0.35.19

2 years ago

0.35.17

2 years ago

0.35.18

2 years ago

0.35.15

2 years ago

0.35.16

2 years ago

0.35.13

2 years ago

0.35.14

2 years ago

0.30.2

2 years ago

0.30.1

2 years ago

0.30.0

2 years ago

0.32.14

2 years ago

0.32.13

2 years ago

0.32.12

2 years ago

0.32.11

2 years ago

0.32.10

2 years ago

0.35.5

2 years ago

0.35.4

2 years ago

0.35.3

2 years ago

0.35.2

2 years ago

0.35.1

2 years ago

0.35.0

2 years ago

0.35.9

2 years ago

0.35.8

2 years ago

0.35.7

2 years ago

0.35.6

2 years ago

0.31.1

2 years ago

0.31.0

2 years ago

0.29.0

2 years ago

0.27.2

2 years ago

0.27.1

2 years ago

0.27.0

2 years ago

0.27.4

2 years ago

0.29.1

2 years ago

0.27.3

2 years ago

0.28.1

2 years ago

0.28.0

2 years ago

0.26.4

2 years ago

0.20.1

2 years ago

0.20.0

2 years ago

0.19.0

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.13.0

2 years ago

0.11.2

2 years ago

0.11.3

2 years ago

0.15.0

2 years ago

0.17.0

2 years ago

0.25.0

2 years ago

0.23.0

2 years ago

0.21.2

2 years ago

0.21.1

2 years ago

0.9.0

2 years ago

0.21.0

2 years ago

0.18.1

2 years ago

0.10.1

2 years ago

0.12.0

2 years ago

0.12.1

2 years ago

0.14.0

2 years ago

0.12.2

2 years ago

0.12.3

2 years ago

0.16.0

2 years ago

0.12.4

2 years ago

0.12.5

2 years ago

0.18.0

2 years ago

0.10.0

2 years ago

0.26.3

2 years ago

0.26.2

2 years ago

0.26.1

2 years ago

0.26.0

2 years ago

0.24.2

2 years ago

0.24.1

2 years ago

0.24.0

2 years ago

0.22.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago