Bolboa Bolboa - 10 months ago 39
Node.js Question

trying to render two different pages using two different entry points webpack

My webpack is partitioned to produce two outputs...

entry: {
a: './src',
b: './Authentication'

devtool: 'source-map',
output: {
filename: 'scripts/[name].js',
publicPath: '/'

So one of my html file (login.html) will call...

<script type="text/javascript" src='scripts/a.entry.js'></script>

And the other (index.html) calls...

<script type="text/javascript" src='./scripts/b.js'></script>

Now each of these pages is a different route. Obviously
will be the main so in my server I did...

var path = require('path');
app.get('/', function(req, res){

Everything renders find when I test it on local. But now I want to access the second
on a different route, I added this...

app.get('/login', function (req, res) {

But when I go to
I get this error...

GET http://localhost:3000/scripts/a.entry.js 404 (Not Found)

The output is not found. Why is this so???

Answer Source

You configured your bundle for login.html to be named “a”, not “a.entry”. Try changing your script tag to:

<script src='scripts/a.js'></script>

(you don't need type="text/javascript" anymore in 2016)