0

I'm trying to setup neutrino for my web project. Configuring it seems really easy and straightforward, however I can't get watch mode (start) to work at all and I have no idea why...

For testing I have a clean, test-only setup for neutrinojs 8.3.0 with minimal config and one simple index.js file in the /src folder. If I run yarn build it works well, files are generated to the /build directory as excepted (index, runtime, manifest), no errors.

But if I run yarn start, and change something in index.js, I can see the Source changed, re-compiling message in terminal then √ Build completed but none of the files in /build were changed, hashes are the same they was before.

If I delete everything from /build and run yarn start again, it says again that √ Build completed but the /build dir is empty, no files generated.

I can't understand, it should just work. Did I miss something? Or is it a bug in neutrino or webpack 3.12.0? Should I create an issue?

I'm using VS Code which is not using "safe-write" so that's not an issue here... I've tried it on windows and linux, same for both.

src/index.js:

console.log('hello world');

.neutrinorc.js:

module.exports = {
    use: [
        ['@neutrinojs/web', {
            html: false
        }]
    ]
};

package.json:

{
  "name": "neutrino",
  "version": "1.0.0",
  "main": "src/index.js",
  "license": "MIT",
  "scripts": {
    "start": "neutrino start",
    "build": "neutrino build"
  },
  "devDependencies": {
    "@neutrinojs/web": "^8.3.0",
    "neutrino": "^8.3.0"
  }
}
szegheo
  • 4,175
  • 4
  • 31
  • 35
  • May I ask why you are passing `html: false`? – Eli Sep 05 '18 at 17:47
  • @Eli Actually my app is a Laravel project and I'm trying to move from its builtin laravel-mix (webpack wrapper) to neutrino. Laravel uses its blade template engine and there is no index.html, instead app.blade.php This template file then uses the generated manifest.json file to read the hashed asset filenames. – szegheo Sep 05 '18 at 18:49

1 Answers1

3

I can't understand, it should just work. Did I miss something? Or is it a bug in neutrino or webpack 3.12.0? Should I create an issue?

Neutrino under the hood uses webpack-dev-server which uses webpack-dev-middleware and as you can see on the first section of the READMEfile:

No files are written to disk, rather it handles files in memory

That is what is happening. Files are written into memory and webpack is able to serve them. That is why you can see your application.

PlayMa256
  • 6,603
  • 2
  • 34
  • 54
  • pffh... @PlayMa256 thanks! Spent my whole day reading documentation on neutrino and webpack but somehow I missed this part. I'll check that writeToDisk option tomorrow... – szegheo Sep 05 '18 at 18:43
  • you don't actually need that writeToDisk. It works totally fine without it – PlayMa256 Sep 05 '18 at 18:53
  • 1
    @ARS81 seconding what has been said here. You don't need those files when serving with start. Have a look at https://github.com/timkelty/HappyLager/blob/neutrino/.neutrinorc.js. This is Craft CMS setup, but the concept should be the same. Notably, you probably need to set publicPath. You need to have some mechanism to serve manifest paths for a built version, but un-hashed paths for dev-server (neutrino start) – Tim Kelty Sep 07 '18 at 16:14
  • @TimKelty thanks, meanwhile I've also found that craftcms repo and yes, that helped me a lot to do the same successfully for Laravel. So now it works but currently my solution uses two mains/entries (index and vendors) and I think it's not the best... Now I'm trying to do it with one index.js entry with automatic js vendor extraction from node_modules and css extraction. In the end I need 4 files: index.js, index.css, vendor.js, vendor.css (haven't succeed yet, I'm still new to this whole webpack thing. Gulp was much easier to understand...) – szegheo Sep 07 '18 at 17:26
  • @ARS81 it's true, figuring out Webpack as a build process with a server-rendered system takes some getting used to. It's worth it though. Feel free to contact me if you want some help. – Tim Kelty Sep 09 '18 at 04:06