Nativescript: Webstorm compatible webpack.config.js

Created on 26 Oct 2018  路  6Comments  路  Source: NativeScript/NativeScript

Webstorm doesn't seem to like the default webpack.config.js when i open up webstorm i get this notice.

    Can't analyse webpack.config.js: coding assistance will ignore module resolution rules in this file.
                Possible reasons: this file is not a valid webpack configuration file or its format is not currently supported by the IDE.
                Error details:  You need to provide a target platform!

Everything seems to be okay except when refactoring an export const webstorm doesnt give out error messages until i open up files that uses that exported const manually. Although I can see the error in the tns run console messages.

Most helpful comment

@tsonevn - Actually this is caused by the webpack config that NativeScript uses.

Your line of code here:
image
Causes this to fail to be evaluated inside the *storm editors...

If you do this:
image

It works... Because now the nativescript webpack config is no longer throwing an error, because the platform is set to "android". :)

All 6 comments

Hi @andrewvmail,
I have created a sample NativeScript project using Webstorm and was able to build the project successfully with tns run <platform_name> --bundle without facing the problem mentioned above.
I also made some research and found a similar issue reported here, however, I do not think that NativeScript is responsible for this error.

Hi @tsonevn Thanks so much!
I was Googling around I missed that.
Okay will figure it out from here. I'll post back when I have something.

@tsonevn - Actually this is caused by the webpack config that NativeScript uses.

Your line of code here:
image
Causes this to fail to be evaluated inside the *storm editors...

If you do this:
image

It works... Because now the nativescript webpack config is no longer throwing an error, because the platform is set to "android". :)

that solution does not work at all for me :(

Yeah, things have changed in the webpack file since then. For webstorm to read it properly you need to use the above fix; and you need to change:
appPath = "src",
to
appPath = "app",

However, I don't know if webpack can actually build the app with that change -- I honestly haven't checked; just made Webstorm to read the webpack config file properly...

Thank you so much sir, the method actually worked like a charm, and it does compile on both Ios and android

Was this page helpful?
0 / 5 - 0 ratings

Related issues

atanasovg picture atanasovg  路  50Comments

tjvantoll picture tjvantoll  路  46Comments

Dimitrievskislavcho picture Dimitrievskislavcho  路  51Comments

morningrat picture morningrat  路  67Comments

surdu picture surdu  路  63Comments