Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

feat: Configure the vendor scripts to also use less, sass, scss for app.css #343

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions demo/TypeScriptApp/app/bundle-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,4 @@ if ((<any>global).TNS_WEBPACK) {
// This will register each xml, css, js, ts, scss etc. in the app/ folder
const context = (<any>require).context("~/", true, /page\.(xml|css|js|ts|scss)$/);
global.registerWebpackModules(context);

console.log("Register:");
context.keys().forEach(key => {
console.log(" - " + key);
});

}
3 changes: 2 additions & 1 deletion templates/vendor.angular.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Snapshot the ~/app.css and the theme
const application = require("application");
require("ui/styling/style-scope");
global.registerModule("app.css", function() { return require("~/app.css"); });
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
global.registerWebpackModules(appCssContext);
application.loadAppCss();

require("./vendor-platform");
Expand Down
3 changes: 2 additions & 1 deletion templates/vendor.nativescript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Snapshot the ~/app.css and the theme
const application = require("application");
require("ui/styling/style-scope");
global.registerModule("app.css", function() { return require("~/app.css"); });
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
global.registerWebpackModules(appCssContext);
application.loadAppCss();

require("./vendor-platform");
Expand Down
16 changes: 9 additions & 7 deletions templates/webpack.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = env => {
throw new Error("You need to provide a target platform!");
}
const platforms = ["ios", "android"];
const mainSheet = "app.css";
const { snapshot, uglify, report, aot } = env;
const ngToolsWebpackOptions = { tsConfigPath: aot ? "tsconfig.aot.json" : "tsconfig.json"};

Expand Down Expand Up @@ -59,12 +58,15 @@ module.exports = env => {
module: {
rules: [
{ test: /\.html$|\.xml$/, use: "raw-loader" },
// Root stylesheet gets extracted with bundled dependencies
{ test: new RegExp(mainSheet), use: "css-loader?url=false" },
// Other CSS files get bundled using the raw loader
{ test: /\.css$/, exclude: new RegExp(mainSheet), use: "raw-loader" },
// SASS support
{ test: /\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },

// tns-core-modules reads the app.css and its imports using css-loader
{ test: /^.\/app\.css$/, use: "css-loader?url=false" },
{ test: /^.\/app\.scss$/, use: ["css-loader?url=false", "sass-loader"] },

// Angular components reference css files and their imports using raw-loader
{ test: /\.css$/, exclude: /^.\/app\.css$/, use: "raw-loader" },
{ test: /\.scss$/, exclude: /^.\/app\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },

// Compile TypeScript files with ahead-of-time compiler.
{ test: /.ts$/, loader: "@ngtools/webpack" },
],
Expand Down
12 changes: 4 additions & 8 deletions templates/webpack.javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = env => {
throw new Error("You need to provide a target platform!");
}
const platforms = ["ios", "android"];
const mainSheet = "app.css";
const { snapshot, uglify, report } = env;

const config = {
Expand Down Expand Up @@ -56,13 +55,10 @@ module.exports = env => {
},
module: {
rules: [
{ test: /\.html$|\.xml$/, use: "raw-loader" },
// Root stylesheet gets extracted with bundled dependencies
{ test: new RegExp(mainSheet), use: "css-loader?url=false" },
// Other CSS files get bundled using the raw loader
{ test: /\.css$/, exclude: new RegExp(mainSheet), use: "raw-loader" },
// SASS support
{ test: /\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },
{ test: /\.(html|xml)$/, use: "raw-loader" },

{ test: /\.css$/, use: "css-loader?url=false" },
{ test: /\.scss$/, use: ["css-loader?url=false", "sass-loader"] },
]
},
plugins: [
Expand Down
13 changes: 5 additions & 8 deletions templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,11 @@ module.exports = env => {
},
module: {
rules: [
{ test: /\.html$|\.xml$/, use: "raw-loader" },
// Root stylesheet gets extracted with bundled dependencies
{ test: new RegExp(mainSheet), use: "css-loader?url=false" },
// Other CSS files get bundled using the raw loader
{ test: /\.css$/, exclude: new RegExp(mainSheet), use: "raw-loader" },
// SASS support
{ test: /\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },
// Compile TypeScript files, replace templateUrl and styleUrls.
{ test: /\.(html|xml)$/, use: "raw-loader" },

{ test: /\.css$/, use: "css-loader?url=false" },
{ test: /\.scss$/, use: ["css-loader?url=false", "sass-loader"] },

{ test: /\.ts$/, use: "awesome-typescript-loader" }
]
},
Expand Down