Last active
March 31, 2021 03:14
-
-
Save krisselden/7a988d65a7481dac1450dc3ae934f692 to your computer and use it in GitHub Desktop.
Embroider App Webpack Dev Server Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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