Great starter kit, but I ran into some trouble integrating with Craft 3 after following the provided instructions.
When switching Mix over from static file building to CMS integration (proxy), the devServer settings should be changed to reflect this as well. e.g. if you don't add a publicPath
setting, webpack reports webpack output is served from https://undefined:undefined/
.
mix.webpackConfig({
devServer: {
clientLogLevel: "none", // Hide console feedback so eslint can take over
open: false,
overlay: true,
port: config.devServerPort,
public: `localhost:${config.devServerPort}`,
host: "0.0.0.0", // Allows access from network
https: config.devProxyDomain.includes("https://"),
contentBase: config.devWatchPaths.length
? config.devWatchPaths
: undefined,
watchContentBase: config.devWatchPaths.length > 0,
publicPath: "/", // <-- for proxy use
...
Another thing that needs to be set is 'useAbsoluteUrl' => false,
in your config/twigpack.php
settings file. If you fail to do so while trying to run the dev server (with HMR), the Twigpack plugin sets the asset path based on Craft's "Site Base" (or FQDN), creating links to assets that don't exist since HMR assets exist in-memory only.
For example, while running the dev server, opening https://localhost:8080
reveals the Craft entry page, but looking at the source, the CSS and JS paths are set to https://my-website.test/dist/main.css
instead of https://localhost:8080/dist/main.css
which would point to the correct in-memory path.
TLDR;
add publicPath: "/",
to Mix's devServer and
'useAbsoluteUrl' => false,
in config/twigpack.php
Anyway, hope this helps anyone else integrating with Craft 3.