NativeScript / nativescript-dev-webpack

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

New css2json-loader fails #1138

Open crowmagnumb opened 4 years ago

crowmagnumb 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):

I can't attach these because the file type of json and js is not allowed in the below attach file section. But they are in a public repo here. As is the scss file I'm showing here. You can actually just clone that repo and reproduce this problem for yourself by running (npm i; gulp dev:android) after replacing webpack.config.js with the version webpack.config.ORIG.js. The latter of which is really just tns run android --env.aot --no-hmr after compiling pug files to html files.

Describe the bug

The following scss file causes webpack.config.js to fail with ...

JS: Error: Could not load CSS from app.css: ReferenceError: undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined is not defined
* {
    font-size: 16;
}

.bigger-font {
    font-size: 24;
}

.big-font {
    font-size: 19;
}

.centered {
    text-align: center;
}

.bold {
    font-weight: bold;
}

.width100 {
    width: 100%;
}

If you comment out the bottom three entries say then it works fine. Various other combinations of commenting out and in of different entries results in success or failure. Only difference being the number of "undefinedundefined...." values.

To Reproduce

See above.

Expected behavior

Not fail to compile bundle.

Sample project

See above.

Additional context

If I change the scss loader in the webpack.config.js file back to the css-loader it was on the last release I had installed, namely ...

diff --git a/webpack.config.js b/webpack.config.js
index f0b43bb..871928d 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -264,8 +264,8 @@ module.exports = env => {
                     use: [
                         "nativescript-dev-webpack/style-hot-loader",
                         {
-                            loader: "nativescript-dev-webpack/css2json-loader",
-                            options: { useForImports: true }
+                            loader: "css-loader",
+                            options: { url: false }
                         },
                         "sass-loader"
                     ]

... then it works fine. So that is what I am doing for now, reverting back to the old loader until this issue is resolved. Cheers.