Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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