Repository navigation
Style with ~path is not resolved correctly #9166
Copy link
Copy link
Closed
Labels
P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulImpacts a large percentage of users; if a workaround exists it is partial or overly painfulseverity3: brokentype: bug/fix
Description
Hi!
I noticed that I cannot build my app properly on Windows, the problem seems to lie in ~ import in sass file (bootstrap specifically), the resolved path looks broken because it is doubled, take a look at the log
I guess the problem was caused by this code 9caa7ca#diff-aa06fda1fc53d1b1e6d1259f3cf4ca2d .
The resolved path for fonts becomes c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass ssets�onts�ootstrapglyphicons-halflings-regular.eot
Versions
Angular CLI: 1.6.3
Node: 8.9.4
OS: win32 x64
Angular: 5.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.2
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.6.2
webpack: 3.10.0
Repro steps
- install @angular/cli@1.6.3
- create new project with scss styles
- install bootstrap@3.3.7 and bootstrap-sass@3.3.7
- in src/styles.scss set
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';at the top - then below add
@import "~bootstrap-sass/assets/stylesheets/bootstrap"; - try to ng serve or ng build
Observed behavior
ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/styles.scss
Module not found: Error: Can't resolve './c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot' in 'c:\vhosts\frontend-client\src'
resolve './c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot' in 'c:\vhosts\frontend-client\src'
using description file: c:\vhosts\frontend-client\package.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
after using description file: c:\vhosts\frontend-client\package.json (relative path: ./src)
using description file: c:\vhosts\frontend-client\package.json (relative path: ./src/c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot)
no extension
Field 'browser' doesn't contain a valid alias configuration
c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot.js doesn't exist
as directory
c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot doesn't exist
[c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot]
[c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot.ts]
[c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot.js]
[c:\vhosts\frontend-client\src\c:vhosts�rontend-clientnode_modules�ootstrap-sass
ssets�onts�ootstrapglyphicons-halflings-regular.eot]
@ ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/styles.scss 7:4344-4479 7:4510-4645
@ ./src/styles.scss
@ multi ./src/styles.scss
Desired behavior
Successful build
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulImpacts a large percentage of users; if a workaround exists it is partial or overly painfulseverity3: brokentype: bug/fix
Activity
jameslafferty commentedon Jan 12, 2018
I think this is related to angular/angular#20676
cpboyd commentedon Jan 12, 2018
@jameslafferty I'm not sure this is entirely related, as I had zero issues with importing the Material Design Icons until the most recent angular-cli version.
The issue seems to be that the new
postcss-importjust chucks the imported CSS file inside of the one importing it, without resolving relative paths.As a temporary quick fix, you can simply copy the font files to your project's local styles folder.
jtsom commentedon Jan 12, 2018
Not limite to Window or sass. Using the directions to import the style sheets for Material results in a broken build:
in styles.css:
results in:
Artux-White commentedon Jan 12, 2018
Similar problem here, when upgrading the @angular/cli from 1.6.3 to 16.4
ERROR in ./node_modules/css-loader?{"sourceMap":false,"import":false}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/styles.scss Module build failed: Error: Can't resolve '~font-awesome/css/font-awesome.css' in '/Users/arturo/Desktop/lab-admin/src' at onError (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/Resolver.js:61:15) at loggingCallbackWrapper (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at runAfter (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/Resolver.js:158:4) at innerCallback (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/Resolver.js:146:3) at loggingCallbackWrapper (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/Users/arturo/Desktop/lab-admin/node_modules/tapable/lib/Tapable.js:252:11) at /Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:40:4 at loggingCallbackWrapper (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at runAfter (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/Resolver.js:158:4) at innerCallback (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/Resolver.js:146:3) at loggingCallbackWrapper (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/Users/arturo/Desktop/lab-admin/node_modules/tapable/lib/Tapable.js:252:11) at innerCallback (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/Resolver.js:144:11) at loggingCallbackWrapper (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/Users/arturo/Desktop/lab-admin/node_modules/tapable/lib/Tapable.js:249:35) at resolver.doResolve.createInnerCallback (/Users/arturo/Desktop/lab-admin/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:44:6) @ ./src/styles.scss 4:14-191 @ multi ./src/styles.scssI had to downgrade back to 1.6.3...
alvachien commentedon Jan 12, 2018
Meet the same issue.
pesoklp13 commentedon Jan 12, 2018
Same issue here.
In my case there is build outside angular project directory
_ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _| | | | |/ ` | '__| | | | | | |/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
Angular CLI: 1.6.4
Node: 6.10.0
OS: win32 x64
Angular: 5.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.4
@angular-devkit/build-optimizer: 0.0.37
@angular-devkit/core: 0.0.24
@angular-devkit/schematics: 0.0.45
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.4
@schematics/angular: 0.1.12
typescript: 2.4.2
webpack: 3.10.0`
ERROR in ./src/styles.scss Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve './cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff' in 'c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\fronten d\src' at factoryCallback (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\webpack\lib\Compilation.js:276:40) at factory (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\webpack\lib\NormalModuleFactory.js:235:20) at resolver (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\webpack\lib\NormalModuleFactory.js:60:20) at asyncLib.parallel.e (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\webpack\lib\NormalModuleFactory.js:127:20) at c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\async\dist\async.js:3874:9 at c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\async\dist\async.js:473:16 at iteratorCallback (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\async\dist\async.js:1048:13) at c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\async\dist\async.js:958:16 at c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\async\dist\async.js:3871:13 at resolvers.normal.resolve (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\webpack\lib\NormalModuleFactory.js:119:22) at onError (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\enhanced-resolve\lib\Resolver.js:65:10) at loggingCallbackWrapper (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19) at runAfter (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\enhanced-resolve\lib\Resolver.js:158:4) at innerCallback (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\enhanced-resolve\lib\Resolver.js:146:3) at loggingCallbackWrapper (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19) at next (c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\node_modules\tapable\lib\Tapable.js:252:11) @ ./src/styles.scss @ multi ./node_modules/font-awesome/css/font-awesome.min.css ./node_modules/primeng/resources/primeng.min.css ./node_modules/bootstrap/dist/css/bootstrap.css ./src/styles.scss ERROR in ./src/styles.scss Module not found: Error: Can't resolve './cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff' in 'c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src' resolve './cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff' in 'c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src' using description file: c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\package.json (relative path: ./src) Field 'browser' doesn't contain a valid alias configuration after using description file: c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\package.json (relative path: ./src) using description file: c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\package.json (relative path: ./src/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) no extension Field 'browser' doesn't contain a valid alias configuration c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff.ts doesn't exist .js Field 'browser' doesn't contain a valid alias configuration c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff.js doesn't exist as directory c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff doesn't exist [c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff] [c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff.ts] [c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff.js] [c:\Users\psokolik.TEMPEST\WORKSPACE\m2m-portal\portals\frontend\src\cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff] @ ./src/styles.scss 7:232-293 @ multi ./node_modules/font-awesome/css/font-awesome.min.css ./node_modules/primeng/resources/primeng.min.css ./node_modules/bootstrap/dist/css/bootstrap.css ./src/styles.scssbaggior commentedon Jan 12, 2018
same issue just after the upgrade from @angular/cli 1.6.3 to 1.6.4
ERROR in ./node_modules/css-loader?{"sourceMap":false,"import":false}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./src/styles.css
Module build failed: Error: Can't resolve '~font-awesome/css/font-awesome.min.css' in 'D:\PRJ\GIT\PCE\pce-webui\src'
at onError (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\Resolver.js:61:15)
at loggingCallbackWrapper (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
at runAfter (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\Resolver.js:158:4)
at innerCallback (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\Resolver.js:146:3)
at loggingCallbackWrapper (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
at next (D:\PRJ\GIT\PCE\pce-webui\node_modules\tapable\lib\Tapable.js:252:11)
at D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:40:4
at loggingCallbackWrapper (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
at runAfter (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\Resolver.js:158:4)
at innerCallback (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\Resolver.js:146:3)
at loggingCallbackWrapper (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
at next (D:\PRJ\GIT\PCE\pce-webui\node_modules\tapable\lib\Tapable.js:252:11)
at innerCallback (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\Resolver.js:144:11)
at loggingCallbackWrapper (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
at next (D:\PRJ\GIT\PCE\pce-webui\node_modules\tapable\lib\Tapable.js:249:35)
at resolver.doResolve.createInnerCallback (D:\PRJ\GIT\PCE\pce-webui\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:44:6)
@ ./src/styles.css 4:14-138
@ multi ./src/styles.css
LanderBeeuwsaert commentedon Jan 12, 2018
jep, confirmed, same issue.
dinerotah commentedon Jan 12, 2018
@baggior Remove '~' from import.
skiabox commentedon Jan 12, 2018
@Taha-Di-Nero This worked but now I am getting an error inside webstorm ('Cannot resolve directory...') maybe from angular service?
Btw this '~' this worked in the past, so I believe it is a bug.
dinerotah commentedon Jan 12, 2018
@skiabox see @clydin #9181 (comment)
clydin commentedon Jan 12, 2018
@Taha-Di-Nero That will cause the defect in the original issue to again manifest.
The original issue was related to CSS url functions and windows path normalization (i.e.,
\vs/). This has been corrected in 1.6.4.This is unconnected to the import issue observed by others in this issue. Of which there are two:
jeremieflahaut commentedon Jan 12, 2018
kylecordes commentedon Jan 19, 2018
This sounds like something that could have easily been prevented by an automated tests, merely trying to build a trivial off-the-shelf Angular Material app (the kind of app you would build following Angular Material quickstart docs). I wonder if the CLI team could be persuaded to include something like that in the CLI test suite?
Markus-Ende commentedon Jan 26, 2018
Still the same error with @angular/cli@1.6.6
Iverson commentedon Feb 1, 2018
Still get same error with 1.6.7
By the way I figured out that error happens only with .css files import.
For example:
but
it looks a bit strange
Iverson commentedon Mar 21, 2018
Is this issue abandoned? @hansl, do you guys have any plans to fix it?
clydin commentedon Mar 21, 2018
@Iverson All of the issues discussed in this thread have been addressed if using the latest stable release (1.7.3). If you are still encountering issues while using this version (within the project), please open a new issue with a minimal reproduction that demonstrates the problem.
angular-automatic-lock-bot commentedon Sep 8, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.