This repository was archived by the owner on Jul 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
misleading webpack.config snippet code #261
Open
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if you follow the lesson and copy the path param in the webpack config snippet code
// webpack.config.js
output: {
path: 'public',
....
}
that will install bundle.js in the public dir but index.html is not yet there, so when you run the browser, it will replace bundle.js with index.html
and it will output a weird error:
SyntaxError: Unexpected token '<'
for a noob like me took me a while to figure it out...
Andersos
commented
Nov 23, 2016
Where are you getting SyntaxError: Unexpected token '<' ?
cormickjbrowne
commented
Dec 17, 2016
This happened to me too. @Andersos you see the SyntaxError: Unexpected token '<' in the browser console. The browser makes a request to /bundle.js but doesn't find the bundle because webpack has put the file at /public/bundle.js. The request continues and when it gets to this section
app.get('*', function (req, res) {
res.sendFile(path.join(__dirname, 'index.html'));
});
express serves index.html again. The browser reads the file and barfs when it tries to interpret the html as javascript.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
if you follow the lesson and copy the path param in the webpack config snippet code
that will install bundle.js in the public dir but index.html isn't there yet and the script src tag of index.html is pointing to root of the dir.
which will lead to output a weird error:
SyntaxError: Unexpected token '<'because the browser somehow will replace bundle.js with index.html...
for a noob like me took me a while to figure it out...