Skip to content

Instantly share code, notes, and snippets.

@krisselden
Last active March 31, 2021 03:14
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save krisselden/7a988d65a7481dac1450dc3ae934f692 to your computer and use it in GitHub Desktop.
Embroider App Webpack Dev Server Config
/* eslint-env node */
const { Webpack } = require("@embroider/webpack");
const variant = {
name: "dev",
runtime: "browser",
optimizeForProduction: false,
};
const webpack = new Webpack(
__dirname,
__dirname + "/dist",
[variant],
console.log.bind(console)
);
const appInfo = webpack.examineApp();
const config = webpack.configureWebpack(appInfo, variant);
config.devServer = {
contentBase: webpack.outputPath,
writeToDisk: true,
before: function (_app, _server, compiler) {
compiler.hooks.done.tapPromise("EmbroiderWriteFiles", async (stats) => {
try {
// embroider expects a multi stats object for variants
const multiStats = { children: [stats.toJson()] };
await webpack.writeFiles(webpack.summarizeStats(multiStats), appInfo);
} catch (e) {
console.error(e);
}
});
},
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment