Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@ export function createCssResourcePlugin(): Plugin {
resolveDir,
});

if (result.errors.length && args.path[0] === '~') {
result.errors[0].notes = [
{
location: null,
text: 'You can remove the tilde and use a relative path to reference it, which should remove this error.',
},
];
}

// Return results that are not files since these are most likely specific to another plugin
// and cannot be loaded by this plugin.
if (result.namespace !== 'file' || !result.path) {
if (result.namespace !== 'file') {
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import { buildEsbuildBrowser } from '../../index';
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';

describeBuilder(buildEsbuildBrowser, BROWSER_BUILDER_INFO, (harness) => {
describe('Behavior: "Stylesheet url() Resolution"', () => {
it('should show a note when using tilde prefix', async () => {
await harness.writeFile(
'src/styles.css',
`
.a {
background-image: url("~/image.jpg")
}
`,
);

harness.useTarget('build', {
...BASE_OPTIONS,
styles: ['src/styles.css'],
});

const { result, logs } = await harness.executeOnce();
expect(result?.success).toBe(false);

expect(logs).toContain(
jasmine.objectContaining({
message: jasmine.stringMatching('You can remove the tilde and'),
}),
);
});
});
});