@@ -2,15 +2,26 @@ var sources = require("webpack-sources");
2
2
var fs = require ( "fs" ) ;
3
3
var path = require ( "path" ) ;
4
4
5
- exports . StyleUrlResolvePlugin = require ( './resource-resolver-plugins/StyleUrlResolvePlugin' ) ;
5
+ var projectDir = path . dirname ( path . dirname ( __dirname ) ) ;
6
+ var packageJsonPath = path . join ( projectDir , "package.json" ) ;
7
+ var packageJson = JSON . parse ( fs . readFileSync ( packageJsonPath , "utf8" ) ) ;
8
+
9
+ var isAngular = Object . keys ( packageJson . dependencies ) . filter ( function ( dependency ) {
10
+ return / ^ @ a n g u l a r \b / . test ( dependency ) ;
11
+ } ) . length > 0 ;
12
+
13
+
14
+ if ( isAngular ) {
15
+ exports . StyleUrlResolvePlugin = require ( "./resource-resolver-plugins/StyleUrlResolvePlugin" ) ;
16
+ }
6
17
7
18
//HACK: changes the JSONP chunk eval function to `global["nativescriptJsonp"]`
8
19
// applied to tns-java-classes.js only
9
20
exports . NativeScriptJsonpPlugin = function ( options ) {
10
21
} ;
11
22
12
23
exports . NativeScriptJsonpPlugin . prototype . apply = function ( compiler ) {
13
- compiler . plugin ( ' compilation' , function ( compilation , params ) {
24
+ compiler . plugin ( " compilation" , function ( compilation , params ) {
14
25
compilation . plugin ( "optimize-chunk-assets" , function ( chunks , callback ) {
15
26
chunks . forEach ( function ( chunk ) {
16
27
chunk . files . forEach ( function ( file ) {
@@ -38,7 +49,7 @@ exports.GenerateBundleStarterPlugin.prototype = {
38
49
var plugin = this ;
39
50
plugin . webpackContext = compiler . options . context ;
40
51
41
- compiler . plugin ( ' emit' , function ( compilation , cb ) {
52
+ compiler . plugin ( " emit" , function ( compilation , cb ) {
42
53
console . log ( " GenerateBundleStarterPlugin: " + plugin . webpackContext ) ;
43
54
44
55
compilation . assets [ "package.json" ] = plugin . generatePackageJson ( ) ;
0 commit comments