|
9 | 9 | import * as fs from 'fs'; |
10 | 10 | import MiniCssExtractPlugin from 'mini-css-extract-plugin'; |
11 | 11 | import * as path from 'path'; |
12 | | -import { Configuration, RuleSetUseItem } from 'webpack'; |
| 12 | +import { Configuration, RuleSetUseItem, WebpackError } from 'webpack'; |
13 | 13 | import { StyleElement } from '../../builders/browser/schema'; |
14 | 14 | import { SassWorkerImplementation } from '../../sass/sass-service'; |
15 | 15 | import { WebpackConfigOptions } from '../../utils/build-options'; |
@@ -112,11 +112,21 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration { |
112 | 112 | } |
113 | 113 |
|
114 | 114 | const sassImplementation = new SassWorkerImplementation(); |
| 115 | + const sassTildeUsageMessage = new Set<string>(); |
| 116 | + |
115 | 117 | extraPlugins.push({ |
116 | 118 | apply(compiler) { |
117 | 119 | compiler.hooks.shutdown.tap('sass-worker', () => { |
118 | 120 | sassImplementation.close(); |
119 | 121 | }); |
| 122 | + |
| 123 | + compiler.hooks.afterCompile.tap('sass-worker', (compilation) => { |
| 124 | + for (const message of sassTildeUsageMessage) { |
| 125 | + compilation.warnings.push(new WebpackError(message)); |
| 126 | + } |
| 127 | + |
| 128 | + sassTildeUsageMessage.clear(); |
| 129 | + }); |
120 | 130 | }, |
121 | 131 | }); |
122 | 132 |
|
@@ -274,6 +284,15 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration { |
274 | 284 | implementation: sassImplementation, |
275 | 285 | sourceMap: true, |
276 | 286 | sassOptions: { |
| 287 | + importer: (url: string, from: string) => { |
| 288 | + if (url.charAt(0) === '~') { |
| 289 | + sassTildeUsageMessage.add( |
| 290 | + `'${from}' imports '${url}' with a tilde. Usage of '~' in imports is deprecated.`, |
| 291 | + ); |
| 292 | + } |
| 293 | + |
| 294 | + return null; |
| 295 | + }, |
277 | 296 | // Prevent use of `fibers` package as it no longer works in newer Node.js versions |
278 | 297 | fiber: false, |
279 | 298 | // bootstrap-sass requires a minimum precision of 8 |
@@ -306,6 +325,15 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration { |
306 | 325 | implementation: sassImplementation, |
307 | 326 | sourceMap: true, |
308 | 327 | sassOptions: { |
| 328 | + importer: (url: string, from: string) => { |
| 329 | + if (url.charAt(0) === '~') { |
| 330 | + sassTildeUsageMessage.add( |
| 331 | + `'${from}' imports '${url}' with a tilde. Usage of '~' in imports is deprecated.`, |
| 332 | + ); |
| 333 | + } |
| 334 | + |
| 335 | + return null; |
| 336 | + }, |
309 | 337 | // Prevent use of `fibers` package as it no longer works in newer Node.js versions |
310 | 338 | fiber: false, |
311 | 339 | indentedSyntax: true, |
|
0 commit comments