Skip to content

Commit 624dac6

Browse files
committed
fix(2.1.1): fix prod builds
closes TrilonIO#12
1 parent e120d8b commit 624dac6

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

.vscode/launch.json

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"name": ".NET Core Launch (web)",
5+
"name": "[Development] Launch Web",
66
"type": "coreclr",
77
"request": "launch",
88
"preLaunchTask": "build",
@@ -32,6 +32,37 @@
3232
"/Views": "${workspaceRoot}/Views"
3333
}
3434
},
35+
{
36+
"name": "[Production] Launch Web",
37+
"type": "coreclr",
38+
"request": "launch",
39+
"preLaunchTask": "build",
40+
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/aspnetcore-angular2-universal.dll",
41+
"args": [],
42+
"cwd": "${workspaceRoot}",
43+
"stopAtEntry": false,
44+
"internalConsoleOptions": "openOnSessionStart",
45+
"launchBrowser": {
46+
"enabled": true,
47+
"args": "${auto-detect-url}",
48+
"windows": {
49+
"command": "cmd.exe",
50+
"args": "/C start ${auto-detect-url}"
51+
},
52+
"osx": {
53+
"command": "open"
54+
},
55+
"linux": {
56+
"command": "xdg-open"
57+
}
58+
},
59+
"env": {
60+
"ASPNETCORE_ENVIRONMENT": "Production"
61+
},
62+
"sourceFileMap": {
63+
"/Views": "${workspaceRoot}/Views"
64+
}
65+
},
3566
{
3667
"name": ".NET Core Attach",
3768
"type": "coreclr",

Client/bootstrap-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { AppBrowserModule } from './app/platform-modules/app.browser.module';
1313

1414
let platform;
1515

16-
if ('production' === process.env.ENV) {
16+
if (process.env.production) {
1717
enableProdMode();
1818
platform = platformUniversalDynamic();
1919
} else {
@@ -27,7 +27,7 @@ const bootApplication = () => platform.bootstrapModule(AppBrowserModule);
2727
// HMR bootstrap overload
2828
const hmrBootstrap = () => { handleHmr(module, bootApplication); };
2929

30-
if ((<any>module).hot) {
30+
if ((<any>module).hot && process.env.development) {
3131
hmrBootstrap();
3232
} else {
3333
bootApplication();

empty.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Used in Prod & AoT builds to pass blank modules
2+
module.exports = {
3+
NgProbeToken: {},
4+
_createConditionalRootRenderer: function(rootRenderer, extraTokens, coreTokens) {
5+
return rootRenderer;
6+
},
7+
__platform_browser_private__: {}
8+
};

webpack.config.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ var clone = require('js.clone');
1111
var ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
1212
var TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin;
1313
var ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
14+
var DefinePlugin = require('webpack/lib/DefinePlugin');
1415

1516
// Test if Development build from ASPNETCore environment
1617
var isDevBuild = process.env.ASPNETCORE_ENVIRONMENT === 'Production' ? false : true;
1718

19+
1820
// Sourcemaps (for Development only)
1921
var devTool = isDevBuild ? 'source-map' : '';
2022

@@ -116,6 +118,12 @@ module.exports = setTypeScriptAlias(require('./tsconfig.json'), {
116118
// (the vendor file has all the 3rd party things we need to get our project going)
117119
plugins: [
118120

121+
new DefinePlugin({
122+
'process.env': {
123+
'development': true
124+
}
125+
}),
126+
119127
new ContextReplacementPlugin(
120128
// The (\\|\/) piece accounts for path separators in *nix and Windows
121129
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
@@ -135,9 +143,17 @@ module.exports = setTypeScriptAlias(require('./tsconfig.json'), {
135143

136144
].concat(isDevBuild ? [] : [
137145
// Plugins that apply in production builds only
146+
new DefinePlugin({
147+
'process.env': {
148+
'production': true
149+
}
150+
}),
138151

139152
// problem with platformUniversalDynamic on the server/client
140-
new webpack.IgnorePlugin(/@angular(\\|\/)compiler/),
153+
new webpack.NormalModuleReplacementPlugin(
154+
/@angular(\\|\/)compiler/,
155+
root('empty.js')
156+
),
141157

142158
//new webpack.optimize.OccurrenceOrderPlugin(), <-- not needed in webpack2 anymore
143159
new webpack.optimize.UglifyJsPlugin()

0 commit comments

Comments
 (0)