@@ -2,6 +2,7 @@ var webpack = require("webpack");
2
2
var nsWebpack = require("nativescript-dev-webpack");
3
3
var path = require("path");
4
4
var CopyWebpackPlugin = require("copy-webpack-plugin");
5
+ var ExtractTextPlugin = require("extract-text-webpack-plugin");
5
6
var path = require("path");
6
7
7
8
module.exports = function(platform, destinationApp) {
@@ -14,6 +15,8 @@ module.exports = function(platform, destinationApp) {
14
15
entry.bundle = "./" + nsWebpack.getEntryModule();
15
16
//Vendor entry with third party libraries.
16
17
entry.vendor = "./vendor";
18
+ //app.css bundle
19
+ entry["app.css"] = "./app.css";
17
20
18
21
return {
19
22
context: path.resolve("./app"),
@@ -30,8 +33,10 @@ module.exports = function(platform, destinationApp) {
30
33
extensions: [
31
34
".ts",
32
35
".js",
36
+ ".css",
33
37
"." + platform + ".ts",
34
38
"." + platform + ".js",
39
+ "." + platform + ".css",
35
40
],
36
41
//Resolve {N} system modules from tns-core-modules
37
42
modules: [
@@ -51,28 +56,44 @@ module.exports = function(platform, destinationApp) {
51
56
test: /\.html$/,
52
57
loader: "raw-loader"
53
58
},
59
+ // Root app.css file gets extracted with bundled dependencies
60
+ {
61
+ test: /app\.css$/,
62
+ loader: ExtractTextPlugin.extract([
63
+ "resolve-url-loader",
64
+ "css-loader",
65
+ "nativescript-dev-webpack/platform-css-loader",
66
+ ]),
67
+ },
68
+ // Other CSS files get bundled using the raw loader
54
69
{
55
70
test: /\.css$/,
56
- loader: "raw-loader"
71
+ exclude: /app\.css$/,
72
+ loaders: [
73
+ "raw-loader",
74
+ ]
57
75
},
76
+ // Compile TypeScript files, replace templateUrl and styleUrls.
58
77
{
59
78
test: /\.ts$/,
60
79
loaders: [
61
80
"awesome-typescript-loader",
62
81
"angular2-template-loader"
63
82
]
64
83
},
84
+ // SASS support
65
85
{
66
86
test: /\.scss$/,
67
87
loaders: [
68
88
"raw-loader",
69
- "resolve-url",
89
+ "resolve-url-loader ",
70
90
"sass-loader"
71
91
]
72
92
},
73
93
]
74
94
},
75
95
plugins: [
96
+ new ExtractTextPlugin("app.css"),
76
97
//Vendor libs go to the vendor.js chunk
77
98
new webpack.optimize.CommonsChunkPlugin({
78
99
name: ["vendor"]
@@ -98,6 +119,6 @@ module.exports = function(platform, destinationApp) {
98
119
]),
99
120
//Required for bundle chunks loading
100
121
new nsWebpack.NativeScriptJsonpPlugin(),
101
- ]
122
+ ],
102
123
};
103
124
};
0 commit comments