I have added "domino" in the server.ts and even updated webpack.server.config.js as :
module: {
rules: [
{ test: /\.(ts|js)$/, loader: 'regexp-replace-loader', options: { match: { pattern: '\\[(Mouse|Keyboard)Event\\]', flags: 'g' }, replaceWith: '[]', } },
{ test: /\.ts$/, loader: 'ts-loader' },
]
}
But still getting the same error : "ReferenceError - KeyboardEvent is not defined".
I am running these commands in terminal
$npm run build:ssr
$npm run serve:ssr
Commands Defined in package.json as :
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "node dist/server.js",
"build:client-and-server-bundles": "ng build --prod && ng run angular.io-example:server",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
Does anybody have an idea, how to get rid of this error?
here you go
const domino = require('domino');
const fs = require('fs');
const template = fs.readFileSync(join(DIST_FOLDER , 'index.html')).toString();
const win = domino.createWindow(template);
global['window'] = win;
global['Node'] = win.Node;
global['navigator'] = win.navigator;
global['Event'] = win.Event;
global['KeyboardEvent'] = win.Event;
global['MouseEvent'] = win.Event;
global['Event']['prototype'] = win.Event.prototype;
global['document'] = win.document;
Put above code into your server.ts
file before the line
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./dist/server/main');
This question is regarding JavaScript. If the input is any of the following array "hello, hi, yo, or hey", I want the value to return true, but it is only returning false. I've tried multiple methods ...
This question is regarding JavaScript. If the input is any of the following array "hello, hi, yo, or hey", I want the value to return true, but it is only returning false. I've tried multiple methods ...
I want set property's value for Polymer object from function, which depended from other properties, if default value not set Polymer({ is: "my-element", properties : { a: String, ...
I want set property's value for Polymer object from function, which depended from other properties, if default value not set Polymer({ is: "my-element", properties : { a: String, ...
If I use this code: Math.floor(Math.random() *6) this will give me a random number from 1 to 5, am I correct? Would it be the same to code this: Math.floor(Math.random() *6)+1 as this? Math....
If I use this code: Math.floor(Math.random() *6) this will give me a random number from 1 to 5, am I correct? Would it be the same to code this: Math.floor(Math.random() *6)+1 as this? Math....
OK I am sure I am doing something simple fundamentally wrong but am unable to resolve this issue on my own. I have tried googling and searching this forum and reading through the relevant parts of the ...
OK I am sure I am doing something simple fundamentally wrong but am unable to resolve this issue on my own. I have tried googling and searching this forum and reading through the relevant parts of the ...