Skip to content
Snippets Groups Projects
server.js 612 B
Newer Older
const port = 9000;
const browserSyncPort = 3000;
const distPath = 'www';

// express server
const { join } = require('path');
const express = require('express');
const app = express();
app
  .use(express.static(distPath))
  // .use('/src', express.static(join(__dirname, 'src')))
  .get(/^[^.]*$/, (req, rep) =>
    rep.sendFile(join(__dirname, distPath, '/index.html')),
  )
  .listen(port);

// browser sync
const bs = require('browser-sync').create();
bs.init({
  files: [distPath + '/**/*'],
  proxy: `http://localhost:${port}`,
  open: false,
  notify: false,
  port: browserSyncPort
  // tunnel: true,
});