ericclemmons / polydev

Faster, route-centric development for Node.js apps with built-in Hot Module Replacement.
282 stars 6 forks source link

Parcel Example #24

Closed ericclemmons closed 5 years ago

ericclemmons commented 5 years ago

This works pretty easily via this:

const Bundler = require("parcel-bundler");
const path = require("path");

const publicPath = path.resolve(__dirname, "../public");
const publicUrl = "./dist";

const bundler = new Bundler(path.resolve(publicPath, "index.html"), {
  outDir: path.resolve(publicPath, publicUrl),
  publicUrl
});

module.exports = bundler.middleware();

But I still want to enable index.*.js to support a package.json.

ericclemmons commented 5 years ago

https://github.com/ericclemmons/back-to-the-fixture/ does this well!

ericclemmons commented 5 years ago

This is even better!

const Bundler = require("parcel-bundler");
const bundler = new Bundler("./src/index.html", { outDir: "./public" });

module.exports = bundler.middleware();

The trick here is to use ./src for the source, and write out to ./public.

(polydev could expose dist, but I think that's not specific enough, since other build tools could expose server-side files to dist)