olange / arcade

A distributed arcade game and mashup of a few delighful arcade games from the eighties — including restoration of an original Pacman Arcade Cocktail table (Karateco 1984)
https://d-arcade.app
Apache License 2.0
1 stars 1 forks source link

Setup toolchain & build system #10

Open olange opened 3 years ago

olange commented 3 years ago

Desired features

Actions

Reference articles

See also

olange commented 3 years ago

About the choice of Snowpack

Why no Rollup in the preliminar study?

Service Workers integration

olange commented 3 years ago

Setting up Babel plugins: decorators and class properties

babel.config.json

{
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }],
    ["@babel/plugin-proposal-class-properties", { "loose": true }]
  ]
}

snowpack.config.js

module.exports = {
  …
  plugins: [ '@snowpack/plugin-babel' ],
  …
};

package.json

{
  …
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "7.12.1",
    "@babel/plugin-proposal-decorators": "7.12.12",
    …
  },
  …
}

About the plugin configuration options

Reference articles

olange commented 3 years ago

About our Snowpack setup

webapp/snowpack.config.js

// Snowpack Configuration File
module.exports = {
  mount: {
    static: { url: "/", static: true },
    // components: { url: "/components" }
  },
  plugins: [ '@snowpack/plugin-babel' ],
  packageOptions: { },
  devOptions: { output: "stream" },
  buildOptions: { out: "build", sourcemap: true },
  optimize: { }
};

Features

Reference articles

olange commented 3 years ago

About the integration of Firebase with Snowpack

Principles

firebase.json

{
  "hosting": {
    "public": "webapp/build",
    "predeploy": "npm run build:webapp",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

package.json

{
  …
  "scripts": {
    …,
    "start": "run-p start:webapp",
    "start:webapp": "npm --prefix webapp run start",
    "start:firebase": "firebase serve --only hosting",
    "build": "run-s build:*",
    "build:webapp": "npm --prefix webapp run build",
    "deploy": "firebase deploy --only hosting"
  },
  …
}

webapp/snowpack.config.js

The buildOptions.out: "build" option of Snowpack states the same folder as the hosting.public: "webapp/build" setting of Firebase (in firebase.json here above):

module.exports = {
  …,
  buildOptions: { out: "build" … },
  …
};
olange commented 3 years ago

Snowpack has support for monorepo layout and packages linked with npm link or NPM Workspaces:

Try to find an example and change the build pipeline to support such layout.

Reference articles

olange commented 2 years ago

We'll need to review our choices, as Snowpack announced last week on their website that they would not actively maintain the project anymore:

« Update (April 20, 2022):

Snowpack is no longer actively maintained and is not recommended for new projects.

Check out Vite for a well-maintained Snowpack alternative. See also: esbuild, parcel »

I guess there is no urgency, the tooling was mature, adopted and they'll fix security issues for a little while. And on our side, we're using the Modern Web Dev stack for the ‹h3-worldmap› web component.

I was not far from using that Modern Web Dev tech stack in January 2021, when I first considered which tooling to use — but settled for Snowpack, as it was simpler to setup, with our various project parts.