1

I'm using Neutrino as scaffolding tool for Webpack 3.1 and I'm looking for a proper Neutrino preset that combines Express and Webpack so that I see a 'Hello World' website. If someone gives me one proper preset and tells me how to install it, I'll accept this as an answer.

Thank you!

user3601578
  • 1,310
  • 1
  • 18
  • 29

1 Answers1

0

This should already be possible with the @neutrinojs/node preset:

// src/index.js

import express from 'express';
import { join } from 'path';

const port = process.env.PORT || 3000;
const app = express();

app.get('/', (request, response) => {
  response.sendFile(join(__dirname, 'index.html'));
});

app.listen(port, () => console.log(`Server running on port ${port}`));
Eli
  • 17,397
  • 4
  • 36
  • 49
  • Thank you. when i install the @neutrinojs/node preset, I get a totally different index.js: import { createServer } from 'http'; import app from './app'; const port = process.env.PORT || 3000; createServer((request, response) => response.end(app())) .listen(port, () => process.stdout.write(`Running on :${port}\n`)); if (module.hot) { module.hot.accept('./app'); } and when I replace the content of it with your post's content, i get: Server running on port 3000 Error: ENOENT: no such file or directory, stat '/home/blabla/neutrino_tutorial_5/build/index.html' – user3601578 Feb 09 '18 at 14:49
  • So, how can I tell Neutrino to build my src/webapp.js (in which my frontend-code is located Jquery etc.) as index.html into the build-folder? – user3601578 Feb 09 '18 at 15:29
  • You may be better off posting a reduced test case repository for me to look at. – Eli Feb 09 '18 at 18:11