NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

Css module import of local file doesn't work #1098

Closed Fatme closed 4 years ago

Fatme commented 4 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug The following syntax doesn't work anymore after updating to NativeScript 6.2:

@import 'common.css';

To Reproduce

  1. tns create myApp --ng
  2. cd myApp && cd src && touch common.css
  3. Open app.css and add @import 'common.css';
  4. tns run ios The following error will be shown:
    ERROR in ./app.css
    Module not found: Error: Can't resolve 'common.css' in '/Users/<myuser>/Work/nativescript-cli/scratch/myApp/src'
    @ ./app.css 3:53-141
    @ ../node_modules/nativescript-dev-webpack/load-application-css-angular.js
    @ ./main.ts
    Executing webpack failed with exit code 2.

Expected behavior

The described syntax is working with NativeScript 6.1 and it should work with NativeScript 6.2. as well.

Additional context

Workaround: The import should be changed with relative path e.g. @import './common.css'

It seems that after changing css-loader with css2json-loader, module imports of .css file doesn't work anymore and only relative imports are supported.

The issue is not reproduced with .scss files.