mizziness / craft3-webpack5-tailwind2-boilerplate

A real-world boilerplate for Craft CMS 3 projects that leverages Wepback 5, Tailwind 2, PostCSS 8, and has a hot-reload dev environment. Now with dynamic imports, asynchronous chunk loading, and legacy vs modern browser support!
MIT License
45 stars 11 forks source link

Cannot get / #4

Closed a-rbsn closed 3 years ago

a-rbsn commented 3 years ago

I'm not sure why but I'm encountering the following issues:

When I go to localhost:8080 I get the following error: Cannot GET / — when I visit the site locally using Valet at domain.test I see the website but none of the CSS is applied. Although this is in DevTools:

<script type="module" src="http://localhost:8080/app.bundle.js"></script>
<script type="module" src="http://localhost:8080/app.bundle.js" nomodule=""></script>
<script type="module" src="http://localhost:8080/chunk-vendors.bundle.js"></script>
<script src="http://localhost:8080/chunk-vendors.bundle.js" nomodule=""></script>

Any thoughts would be greatly appreciated.

Best, Andrew

claysondesign commented 3 years ago

Getting the same error with a Nitro setup. Can't work out what might have changed. Build is fine.

(node:2896) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.

Have searched on “DEP_WEBPACK_WATCH_WITHOUT_CALLBACK” and seems to be a common problem with many potential solutions.

The webpack hot load seems flakier than Browsersync in this setup? I don’t know. Everything else here works a treat :)

Bcdo commented 3 years ago

@claysondesign What is your approach on using this with nitro? I am new with webpack, and I want to test it with nitro, but I get the same issue as described above, and no css or tailwind working.

claysondesign commented 3 years ago

More or less using as this repo and have tried a few amends, but it always falls over worse. All paths and assets set up .env or config/general.php seem to working well when not in dev mode.

Nitro works pretty well, but a little limited (no https). Reliant on Multipass on the Mac and apparently not M1 ready either if you’re lucky enough to go there.

If this nice little stack works on Mamp Pro or Valet that would be interesting.

claysondesign commented 3 years ago

Have tried this now on a fresh install and Nitro 2.03 BETA

Still the same issue but webpack update and search suggests that in package.json scripts to remove the --watch to prevent further errors

Change:

"dev": "cross-env NODE_ENV=development webpack serve --watch --config ./wpconfig/webpack.dev.js",

to

"dev": "cross-env NODE_ENV=development webpack serve --config ./wpconfig/webpack.dev.js",

mizziness commented 3 years ago

Have tried this now on a fresh install and Nitro 2.03 BETA

Still the same issue but webpack update and search suggests that in package.json scripts to remove the --watch to prevent further errors

Change:

"dev": "cross-env NODE_ENV=development webpack serve --watch --config ./wpconfig/webpack.dev.js",

to

"dev": "cross-env NODE_ENV=development webpack serve --config ./wpconfig/webpack.dev.js",

This appears to be correct - webpack-cli 4.4.0 -> 4.5.0 is where the change occurred. Update to the project coming :) Thanks!

claysondesign commented 3 years ago

Looks good. Does this solve the original "Cannot GET /" issue for you?

Still the same for me on Nitro 2.05 BETA

https://testdomain.nitro/ is fine but Webpack watch url doesn't want to know :( https://testdomain.nitro:8080/

williamExitable commented 3 years ago

I have the same problem. When I runyarn dev and I browse to localhost:8080 I get the same message: Cannot get / The Master repo is today installed. In the package.json I have: cross-env NODE_ENV=development webpack serve --mode development --config ./wpconfig/webpack.dev.js

brambeekman commented 3 years ago

I have the same problem. When I runyarn dev and I browse to localhost:8080 I get the same message: Cannot get / The Master repo is today installed. In the package.json I have: cross-env NODE_ENV=development webpack serve --mode development --config ./wpconfig/webpack.dev.js

The same here, any fix?

mizziness commented 3 years ago

@BramBeekman That is because there's no index file in your dist folder - it's not required, though! The asset files are still served. If you try and load one directly, it should work. The latest release includes code and instructions on how to make it generate an index file, if you really want one.

Edit: Here's a link right to the code block you would use: https://github.com/mizziness/craft3-webpack5-tailwind2-boilerplate/blob/main/wpconfig/webpack.common.js#L45-L54

storybynumbers commented 2 years ago

How are you accessing your homepage when the index file is not being generated? How do you access other templates when no files are generated in web/dist in dev mode?

JonQuayle commented 2 years ago

Just chipping in here as I'm also seeing the 'Cannot GET /' message. No errors in the terminal. CSS and JS is being built fine with the build command. I am however using MAMP and I'm not sure how to connect the two? Pretty confused if I'm being honest with how the template files in /templates are getting rendered with Webpack-dev-server?