Skip to content

Commit

Permalink
refactor(demo): fix base href, move universal scripts to subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSurmay committed Oct 27, 2017
1 parent 199cc0b commit e0a2f5b
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { environment } from '../environments/environment';
],
imports: [
DocsModule,
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot(routes, {useHash: environment.useHash}),
Expand Down
1 change: 0 additions & 1 deletion demo/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<meta name="msapplication-navbutton-color" content="#1d1d2b">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="msapplication-starturl" content="/">
<base href="/">
</head>
<body>
<bs-demo>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"view-stats": "webpack-bundle-analyzer demo/dist/stats.json",
"build:dynamic": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:dynamic": "node demo/dist/server.js",
"build:client-and-server-bundles": "ng build --prod --env=server && ng build --prod --env=server --app 1 --output-hashing=false",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
"build:client-and-server-bundles": "ng build -bh / --prod --env=server && ng build -bh / --prod --env=server --app 1 --output-hashing=false",
"webpack:server": "webpack --config ./scripts/universal/webpack.server.config.js --progress --colors"
},
"main": "bundles/ngx-bootstrap.umd.js",
"module": "index.js",
Expand Down
4 changes: 2 additions & 2 deletions prerender.ts → scripts/universal/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { renderModuleFactory } from '@angular/platform-server';
import { ROUTES } from './static.paths';

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./demo/dist/server/main.bundle');
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('../../demo/dist/server/main.bundle');

const BROWSER_FOLDER = join(process.cwd(), 'browser');

Expand All @@ -27,7 +27,7 @@ let previousRender = Promise.resolve();

// Iterate each route path
ROUTES.forEach(route => {
var fullPath = join(BROWSER_FOLDER, route);
const fullPath = join(BROWSER_FOLDER, route);

// Make sure the directory structure is there
if(!existsSync(fullPath)){
Expand Down
2 changes: 1 addition & 1 deletion server.ts → scripts/universal/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DIST_FOLDER = join(process.cwd(), 'demo/dist');
const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString();

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./demo/dist/server/main.bundle');
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('../../demo/dist/server/main.bundle');

const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const path = require('path');
const webpack = require('webpack');

module.exports = {
entry: { server: './server.ts', prerender: './prerender.ts' },
entry: { server: './scripts/universal/server.ts', prerender: './scripts/universal/prerender.ts' },
resolve: { extensions: ['.ts', '.js'] },
target: 'node',
// this makes sure we include node_modules and other 3rd party libraries
externals: [/(node_modules|main\..*\.js)/],
output: {
path: path.join(__dirname, 'demo/dist'),
path: path.join(__dirname, '../../demo/dist'),
filename: '[name].js'
},
module: {
Expand Down

0 comments on commit e0a2f5b

Please sign in to comment.