This repository was archived by the owner on Aug 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-6
lines changed Expand file tree Collapse file tree 1 file changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,28 @@ const getAndroidRuntimeVersion = (projectDir) => {
44
44
}
45
45
}
46
46
47
+ const getWebpackConfig = ( projectDir , configPath = "webpack.config.js" ) => {
48
+ const configAbsolutePath = path . resolve ( projectDir , configPath ) ;
49
+ let config ;
50
+ try {
51
+ config = require ( configAbsolutePath ) ;
52
+ } catch ( e ) {
53
+ throw new Error (
54
+ `Couldn't load webpack config from ${ configAbsolutePath } . ` +
55
+ `Original error:\n${ e } `
56
+ ) ;
57
+ }
58
+ if ( typeof config === "function" ) {
59
+ config = config ( ) ;
60
+ }
61
+
62
+ if ( ! config ) {
63
+ throw new Error ( `Webpack config from ${ configAbsolutePath } is empty!` ) ;
64
+ }
65
+
66
+ return config ;
67
+ } ;
68
+
47
69
const getPackageJson = projectDir => {
48
70
const packageJsonPath = getPackageJsonPath ( projectDir ) ;
49
71
return JSON . parse ( fs . readFileSync ( packageJsonPath , "utf8" ) ) ;
@@ -115,14 +137,15 @@ const resolveAndroidConfigurationsPath = projectDir => {
115
137
const getPackageJsonPath = projectDir => path . resolve ( projectDir , "package.json" ) ;
116
138
117
139
module . exports = {
118
- isTypeScript,
119
- isAngular,
120
- isSass,
121
- writePackageJson,
140
+ getAndroidProjectPath,
141
+ getAndroidRuntimeVersion,
122
142
getPackageJson,
123
143
getProjectDir,
124
- getAndroidRuntimeVersion,
125
- getAndroidProjectPath,
144
+ getWebpackConfig,
145
+ isAngular,
146
+ isSass,
147
+ isTypeScript,
126
148
resolveAndroidAppPath,
127
149
resolveAndroidConfigurationsPath,
150
+ writePackageJson,
128
151
} ;
You can’t perform that action at this time.
0 commit comments