Skip to content

Commit 9cf33e4

Browse files
committed
Add support for platform specific mainSheet
1 parent 2ce3780 commit 9cf33e4

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

templates/webpack.angular.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { resolve, join } = require("path");
2+
const fs = require('fs');
23

34
const webpack = require("webpack");
45
const nsWebpack = require("nativescript-dev-webpack");
@@ -11,11 +12,13 @@ const { AotPlugin } = require("@ngtools/webpack");
1112

1213
const ngToolsWebpackOptions = { tsConfigPath: "tsconfig.aot.json" };
1314

14-
const mainSheet = `app.css`;
15+
let mainSheet = '';
1516

1617
module.exports = env => {
1718
const platform = getPlatform(env);
1819

20+
mainSheet = getMainSheet(platform);
21+
1922
// Default destination inside platforms/<platform>/...
2023
const path = resolve(nsWebpack.getAppPath(platform));
2124

@@ -83,6 +86,12 @@ module.exports = env => {
8386
};
8487

8588

89+
function getMainSheet(platform) {
90+
const mainSheet = `app.${platform}.css`;
91+
return fs.existsSync(join(__dirname, 'app', mainSheet)) ?
92+
mainSheet : 'app.css';
93+
}
94+
8695
function getPlatform(env) {
8796
return env.android ? "android" :
8897
env.ios ? "ios" :

templates/webpack.javascript.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { resolve, join } = require("path");
2+
const fs = require('fs');
23

34
const webpack = require("webpack");
45
const nsWebpack = require("nativescript-dev-webpack");
@@ -8,11 +9,13 @@ const ExtractTextPlugin = require("extract-text-webpack-plugin");
89
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
910

1011

11-
const mainSheet = `app.css`;
12+
let mainSheet = '';
1213

1314
module.exports = env => {
1415
const platform = getPlatform(env);
1516

17+
mainSheet = getMainSheet(platform);
18+
1619
// Default destination inside platforms/<platform>/...
1720
const path = resolve(nsWebpack.getAppPath(platform));
1821

@@ -80,6 +83,12 @@ module.exports = env => {
8083
};
8184

8285

86+
function getMainSheet(platform) {
87+
const mainSheet = `app.${platform}.css`;
88+
return fs.existsSync(join(__dirname, 'app', mainSheet)) ?
89+
mainSheet : 'app.css';
90+
}
91+
8392
function getPlatform(env) {
8493
return env.android ? "android" :
8594
env.ios ? "ios" :

templates/webpack.typescript.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { resolve, join } = require("path");
2+
const fs = require('fs');
23

34
const webpack = require("webpack");
45
const nsWebpack = require("nativescript-dev-webpack");
@@ -8,11 +9,13 @@ const ExtractTextPlugin = require("extract-text-webpack-plugin");
89
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
910

1011

11-
const mainSheet = `app.css`;
12+
let mainSheet = '';
1213

1314
module.exports = env => {
1415
const platform = getPlatform(env);
1516

17+
mainSheet = getMainSheet(platform);
18+
1619
// Default destination inside platforms/<platform>/...
1720
const path = resolve(nsWebpack.getAppPath(platform));
1821

@@ -80,6 +83,12 @@ module.exports = env => {
8083
};
8184

8285

86+
function getMainSheet(platform) {
87+
const mainSheet = `app.${platform}.css`;
88+
return fs.existsSync(join(__dirname, 'app', mainSheet)) ?
89+
mainSheet : 'app.css';
90+
}
91+
8392
function getPlatform(env) {
8493
return env.android ? "android" :
8594
env.ios ? "ios" :

0 commit comments

Comments
 (0)