tailwindlabs / tailwindcss-jit

MIT License
2.19k stars 40 forks source link

Font urls can't be resolved #50

Closed nckrtl closed 3 years ago

nckrtl commented 3 years ago

Without jit it can resolve the urls in app.css with a preceding ../ just fine:

@layer base {
    @font-face {
        font-family: "Inter var";
        font-weight: 100 900;
        font-display: swap;
        font-style: normal;
        font-named-instance: "Regular";
        src: url("../fonts/Inter-roman.var.woff2") format("woff2");
    }
}

With jit enabled it results in error:

ERROR in ./resources/css/app.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/css-loader/dist/cjs.js):
Error: Can't resolve '___CSS_LOADER_URL_REPLACEMENT_0___' in '/Users/nckrtl/code/projects/laravel/nckrtl/resources/css'
    at finishWithoutResolve (/Users/nckrtl/code/projects/laravel/nckrtl/node_modules/enhanced-resolve/lib/Resolver.js:293:18)
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/enhanced-resolve/lib/Resolver.js:362:15
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/enhanced-resolve/lib/Resolver.js:410:5
    at eval (eval at create (/Users/nckrtl/code/projects/laravel/nckrtl/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/enhanced-resolve/lib/Resolver.js:410:5
    at eval (eval at create (/Users/nckrtl/code/projects/laravel/nckrtl/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:87:43
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/enhanced-resolve/lib/Resolver.js:410:5
    at eval (eval at create (/Users/nckrtl/code/projects/laravel/nckrtl/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/enhanced-resolve/lib/Resolver.js:410:5
    at processResult (/Users/nckrtl/code/projects/laravel/nckrtl/node_modules/webpack/lib/NormalModule.js:649:19)
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/webpack/lib/NormalModule.js:743:5
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /Users/nckrtl/code/projects/laravel/nckrtl/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/Users/nckrtl/code/projects/laravel/nckrtl/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at Object.loader (/Users/nckrtl/code/projects/laravel/nckrtl/node_modules/css-loader/dist/index.js:154:5)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)

1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 2 errors

This is running in a basic Laravel project with all latest versions installed.

Edit: It seems to produce this error when the path IS actually correct. If path is incorrect it just gets ignored.

nckrtl commented 3 years ago

When defining the font url like:

src: url(/fonts/Inter-Roman-var.woff2) format("woff2");

It does work.

brentarcane commented 3 years ago

Is it possible to make it work using relative font paths rather than absolute?

nckrtl commented 3 years ago

Hi Brent, not sure. I haven't been looking any further as the absolute path is working fine for me like this.

brentarcane commented 3 years ago

This was fixed in v0.1.7 👍

nckrtl commented 3 years ago

Ah good to know! Thanks