question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

css url() is not relative to publicPath

See original GitHub issue

Do you want to request a feature or report a bug?

Seems like a bug What is the current behaviour?

Even after setting on config a new publicPath and this is being observed on js files:

import previous from './preact.config.js';

export default function (config, env, helpers) {
    config.output.publicPath = '/wp-content/themes/nsp/';
    return config;
}

The CSS files with sentences like background-image: url('/assets/images/nsp-complete.png');

the output css bundles returns these rules with the same path

What is the expected behaviour?

IMHO honoring public path should be background-image: url(/wp-content/themes/nsp’/assets/images/nsp-complete.png’);`

Currently I’m updating all references using a small script:

egrep -lRZ '/assets' wp-theme/ | xargs -0 -l sed -i -e 's/\/assets/\/wp-content\/themes\/nsp\/assets/g'

Thanks for your time reading this.

Please paste the results of preact info here.

Environment Info: System: OS: Linux 5.4 elementary OS 5.1.7 Hera CPU: (4) x64 Intel® Core™ i5-6200U CPU @ 2.30GHz Binaries: Node: 12.18.3 - /usr/bin/node Yarn: 1.22.4 - /usr/bin/yarn npm: 6.14.6 - /usr/bin/npm Browsers: Chrome: 84.0.4147.125 npmPackages: preact: ^10.3.2 => 10.4.7 preact-cli: ^3.0.0 => 3.0.1 preact-render-to-string: ^5.1.4 => 5.1.10 preact-router: ^3.2.1 => 3.2.1

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
developitcommented, Sep 13, 2020

@RyanChristian4427 - I wonder if it’d be worth having CLI infer the publicPath value for MiniCssExtract from the config?

Something like this to replace these lines:

					use: [
						isWatch ? 'style-loader' : {
							loader: MiniCssExtractPlugin.loader,
							options: {
								get publicPath() {
									// `config` is a new variable assigned to the returned object from L113
									return config.output && config.output.publicPath;
								}
							}
						},
						{
1reaction
Edorkacommented, Sep 16, 2020

I don’t know if it would worth the bytes to opena a new issue: This also affects manifest.json icon paths

Read more comments on GitHub >

github_iconTop Results From Across the Web

url-loader / file-loader breaking relative paths in css output ...
I've tried using resolve-url-loader, specifying publicPath and outputPath, and of course searching for answers online but have had no luck.
Read more >
MiniCssExtractPlugin - webpack
Inserts the link tag at the given position for non-initial (async) CSS chunks ... context) => { // publicPath is the relative path...
Read more >
Static Asset Handling - Vite
url() references in CSS are handled the same way. If using the Vue plugin, asset references in Vue SFC templates are automatically converted...
Read more >
Absolute / domain-relative path for asset URLs in CSS - bud
<?php namespace App; use function Roots\asset; add_action('after_setup_theme', function () { // Add frontend styles as editor styles add_editor_style(asset('app ...
Read more >
HTML and Static Assets - Vue CLI
When you reference a static asset using relative path (must start with . ) inside JavaScript, CSS or *.vue files, the asset will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found