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

Commit b207ef6

Browse files
committed
Add angular2-template-loader. Comments in webpack.config
1 parent 595921e commit b207ef6

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

postinstall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ configureDevDependencies(packageJson, function(add) {
4343
add("webpack-sources", "~0.1.2");
4444
add("copy-webpack-plugin", "~3.0.1");
4545
add("awesome-typescript-loader", "~2.2.4");
46-
add("html-loader", "~0.4.3");
46+
add("angular2-template-loader", "~0.6.0");
4747
add("raw-loader", "~0.5.1");
4848
});
4949

webpack.common.js.template

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
var webpack = require("webpack");
22
var nsWebpack = require("nativescript-dev-webpack");
3-
var sources = require("webpack-sources");
43
var path = require("path");
5-
var CopyWebpackPlugin = require('copy-webpack-plugin');
6-
var fs = require("fs");
4+
var CopyWebpackPlugin = require("copy-webpack-plugin");
75
var path = require("path");
86

97
module.exports = function(platform, destinationApp) {
108
if (!destinationApp) {
9+
//Default destination inside platforms/<platform>/...
1110
destinationApp = nsWebpack.getAppPath(platform);
1211
}
1312
var entry = {};
13+
//Discover entry module from package.json
1414
entry.bundle = "./" + nsWebpack.getEntryModule();
15+
//Vendor entry with third party libraries.
1516
entry.vendor = "./vendor";
1617

1718
return {
@@ -25,12 +26,14 @@ module.exports = function(platform, destinationApp) {
2526
jsonpFunction: "nativescriptJsonp"
2627
},
2728
resolve: {
29+
//Resolve platform-specific modules like module.android.js
2830
extensions: [
2931
".ts",
3032
".js",
3133
"." + platform + ".ts",
3234
"." + platform + ".js",
3335
],
36+
//Resolve {N} system modules from tns-core-modules
3437
modules: [
3538
"node_modules/tns-core-modules",
3639
"node_modules"
@@ -46,38 +49,54 @@ module.exports = function(platform, destinationApp) {
4649
loaders: [
4750
{
4851
test: /\.html$/,
49-
loader: "html-loader"
52+
loader: "raw-loader"
53+
},
54+
{
55+
test: /\.css$/,
56+
loader: "raw-loader"
5057
},
5158
{
5259
test: /\.ts$/,
53-
loader: 'awesome-typescript-loader'
60+
loaders: [
61+
"awesome-typescript-loader",
62+
"angular2-template-loader"
63+
]
5464
},
5565
{
5666
test: /\.scss$/,
5767
loaders: [
58-
'raw-loader', 'resolve-url', 'sass'
68+
"raw-loader",
69+
"resolve-url",
70+
"sass-loader"
5971
]
6072
},
6173
]
6274
},
6375
plugins: [
76+
//Vendor libs go to the vendor.js chunk
6477
new webpack.optimize.CommonsChunkPlugin({
6578
name: ["vendor"]
6679
}),
80+
//Define useful constants like TNS_WEBPACK
6781
new webpack.DefinePlugin({
68-
global: 'global',
69-
__dirname: '__dirname',
70-
"global.TNS_WEBPACK": 'true',
82+
global: "global",
83+
__dirname: "__dirname",
84+
"global.TNS_WEBPACK": "true",
7185
}),
86+
//Copy assets to out dir. Add your own globs as needed.
7287
new CopyWebpackPlugin([
73-
{ from: "**/*.css" },
74-
{ from: "**/*.html" },
75-
{ from: "**/*.xml", ignore: "App_Resources/**" },
76-
]),
88+
{from: "app.css"},
89+
{from: "css/**"},
90+
{from: "**/*.jpg"},
91+
{from: "**/*.png"},
92+
{from: "**/*.xml"},
93+
], {ignore: ["App_Resources/**"]}),
94+
//Generate a bundle starter script and activate it in package.json
7795
new nsWebpack.GenerateBundleStarterPlugin([
7896
"./vendor",
7997
"./bundle",
8098
]),
99+
//Required for bundle chunks loading
81100
new nsWebpack.NativeScriptJsonpPlugin(),
82101
]
83102
};

0 commit comments

Comments
 (0)