Skip to content

SyntaxError: unknown: Unexpected token (import) #102

Open
@jdferreira

Description

@jdferreira

I'm not sure what the correct forum is to ask for help; if you think this is not the place, please direct me towards a better alternative.

I'm starting to learn webpack, following a tutorial which uses html-loader, extract-loader and file-loader. When I apply the extract-loader to an HTML file that depends on a CSS and JS file, webpack seems to be unable to compile the HTML:

Here's a snippet of the error.

SyntaxError: unknown: Unexpected token (3:83)
  1 | // Imports
  2 | import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../node_modules/html-loader/dist/runtime/getUrl.js";
> 3 | var ___HTML_LOADER_IMPORT_0___ = new URL("./9e9623e0b9c680a171a9f50add100517.css", import.meta.url);
    |                                                                                    ^
  4 | // Module
  5 | var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);

It seems there is a problem with the import keyword.

Is there a way to solve this issue or am I missing understanding somewhere?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions