Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack5 use extract-loader to extract html file,but extract-loader always report error. #111

Open
jyp114110 opened this issue Aug 25, 2021 · 3 comments

Comments

@jyp114110
Copy link

I use html-loader and extract-laoder to extract html file, but extractorLoder.js always report errors. My config is:
const pathToIndexHtml = require.resolve("./src/file.html"); const pathToMainJs = require.resolve("./src/index.js"); module.exports = { entry: [ pathToMainJs, pathToIndexHtml ], output: { assetModuleFilename: "[name][ext]", }, module: { rules: [ { test: pathToIndexHtml, type: "asset/resource", generator: { filename: "[name][ext]", }, }, { test: pathToIndexHtml, use: [ "extract-loader","html-loader"], }, ], }, };
And use Official website example also report same error. Error is:

Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
SyntaxError: unknown: Unexpected token (3:62)
import 'HTML_LOADER_GET_SOURCE_FROM_IMPORT' from "../node_modules/html-loader/dist/runtime/getUrl.js";
var 'HTML_LOADER_IMPORT_0' = new URL("./images/nhlt.jpg", import.meta.url);

import can not been properly disposed

@shoaibsharif
Copy link

I am also facing the same issue. Did you find an workaround?

@GiantTreeLP
Copy link

Set esModule to false in both html-loader and css-loader

@Mario-Eis
Copy link

Set esModule to false in both html-loader and css-loader

With url(./whatever.woff) in the file, this raises another error

2023-12-13 14_44_59-fiva-office-app – webpack js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants