Skip to content

Commit 74b8876

Browse files
committed
chore: webpack dist handling per flavor
1 parent 0cd355d commit 74b8876

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

bin/build-nativescript.js

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,29 @@ const checkFramework = () => {
3030
name: 'webpack.config.js',
3131
version: 5
3232
};
33-
// As of 9/9/2021, Capacitor 3.0.0:
34-
// angular: webpack5
35-
// react: webpack4
36-
// vue: webpack4
37-
const packagePath = join(projectDir, 'package.json');
38-
const packageContent = fs.readFileSync(packagePath, {
39-
encoding: 'UTF-8',
40-
});
41-
if (packageContent) {
42-
const packageJson = JSON.parse(
43-
stripJsonComments(packageContent),
44-
);
45-
if (packageJson && packageJson.dependencies) {
46-
isReact = !!packageJson.dependencies['react'];
47-
isVue = !!packageJson.dependencies['vue'];
48-
if (isReact || isVue) {
49-
webpackInfo = {
50-
name: 'webpack4.config.js',
51-
version: 4
52-
};
53-
} else {
54-
isAngular = true;
55-
}
56-
}
57-
}
33+
34+
// Note: Left here in case other flavor integrations end up using older webpack
35+
// const packagePath = join(projectDir, 'package.json');
36+
// const packageContent = fs.readFileSync(packagePath, {
37+
// encoding: 'UTF-8',
38+
// });
39+
// if (packageContent) {
40+
// const packageJson = JSON.parse(
41+
// stripJsonComments(packageContent),
42+
// );
43+
// if (packageJson && packageJson.dependencies) {
44+
// isReact = !!packageJson.dependencies['react'];
45+
// isVue = !!packageJson.dependencies['vue'];
46+
// if (isVue) {
47+
// webpackInfo = {
48+
// name: 'webpack4.config.js',
49+
// version: 4
50+
// };
51+
// } else {
52+
// isAngular = true;
53+
// }
54+
// }
55+
// }
5856
};
5957

6058
const buildNativeScript = () => {
@@ -128,26 +126,27 @@ const npmInstallTsPatch = () => {
128126

129127
const npmInstall = () => {
130128

131-
if (isReact) {
132-
// Exception case: React needs ts-loader ^6.2.2 installed
133-
const child = spawn(`npm`, ['install', '[email protected]', '-D'], {
134-
cwd: resolve(buildDir),
135-
stdio: 'inherit',
136-
shell: true,
137-
});
138-
child.on('error', (error) => {
139-
console.log('NativeScript build error:', error);
140-
});
141-
child.on('close', (res) => {
142-
child.kill();
143-
installTsPatch();
144-
});
145-
} else {
129+
// Note: Left in case flavor integrations need any different dependencies in future
130+
// if (isReact) {
131+
// // Exception case: React needs ts-loader ^6.2.2 installed
132+
// const child = spawn(`npm`, ['install', '[email protected]', '-D'], {
133+
// cwd: resolve(buildDir),
134+
// stdio: 'inherit',
135+
// shell: true,
136+
// });
137+
// child.on('error', (error) => {
138+
// console.log('NativeScript build error:', error);
139+
// });
140+
// child.on('close', (res) => {
141+
// child.kill();
142+
// installTsPatch();
143+
// });
144+
// } else {
146145
// Vue projects bring in ts-loader 6.2.2 through vue cli dependencies
147146
// Angular project use webpack5 and can use the latest with @nativescript/webpack
148147
// proceed as normal
149148
npmInstallTsPatch();
150-
}
149+
// }
151150
}
152151

153152
if (!installOnly) {

src_bridge/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const TerserPlugin = require("terser-webpack-plugin");
33
const { resolve } = require("path");
44
module.exports = (env) => {
55
const mode = env.production ? 'production' : 'development';
6+
const distFolder = env.distFolder || 'www';
67
webpack.init(env);
78
webpack.useConfig(false);
89
webpack.chainWebpack((config) => {
@@ -19,7 +20,7 @@ module.exports = (env) => {
1920
webpack.Utils.project.getProjectFilePath("./index.ts")
2021
);
2122
config.output
22-
.path(webpack.Utils.project.getProjectFilePath("../../www/nativescript"))
23+
.path(webpack.Utils.project.getProjectFilePath(`../../${distFolder}/nativescript`))
2324
.pathinfo(false)
2425
.publicPath("")
2526
.libraryTarget("commonjs")

0 commit comments

Comments
 (0)