Hi
In a pug file, If I set an external link for a link tag, it works correctly. For example:
link(rel=“stylesheet”, href=“https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.rtl.min.css”)
But for a local address:
link(rel=“stylesheet”, href=“./style.css”)
Html Webpack Plugin:
Error: webpack://pug/./src/index.pug?./node_modules/html-webpack-plugin/lib/loader.js:9
var HTML_LOADER_IMPORT_0 = new URL(/* asset import / webpack_require(/! ./style.css */ “./src/style.css”), _webpack_require _.b);
^
ReferenceError: URL is not defined
loader.js:9 eval
[index.pug?.]/[html-webpack-plugin]/lib/loader.js:9:34index.pug:30 Object…/node_modules/html-webpack-plugin/lib/loader.js!./src/index.pug
D:/my-own-projects/pug/src/index.pug:30:1index.pug:73 webpack_require
D:/my-own-projects/pug/src/index.pug:73:41index.pug:131
D:/my-own-projects/pug/src/index.pug:131:37index.pug:134
D:/my-own-projects/pug/src/index.pug:134:12index.js:136 HtmlWebpackPlugin.evaluateCompilationResult
[pug]/[html-webpack-plugin]/index.js:136:28index.js:333 Promise.resolve.then
[pug]/[html-webpack-plugin]/index.js:333:26next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
While the style file exist in src folder and I can include it into a style tag.
This is webpack.config.js:
const path = require(‘path’);
const webpack = require(‘webpack’);
const HtmlWebpackPlugin = require(‘html-webpack-plugin’);
const pug = {
test: /\.pug$/, use: [ { loader: 'html-loader', options: { minimize: false } }, { loader: 'pug-html-loader', options: { pretty: true } } ],
};
const config = {
entry: './src/app.js', output: { path: path.resolve(__dirname, 'dist'), filename: '[name].bundle.js' }, module: { rules: [pug] }, plugins: [ new HtmlWebpackPlugin({ filename: 'index.html', template: 'src/index.pug', inject: false, }), ]
};
module.exports = [config];