ko not found in webpack project
Closed this issue · 3 comments
cosmoKenney commented
I'm bundling knockout with webpack. Like issue #6 I get the error: knockout.js is not used in the page (ko is undefined). Maybe you are using iFrames, if so, browse to the url of the frame and try again.
I've tried (this is typescript) in my entry point:
(<any>window).ko = ko;
cosmoKenney commented
Would the webpack ProvidePlugin help with this?
crmtestresco commented
You can use expose loader to make knockout global variable again.
Example configuration:
rules: [
{
test: require.resolve('knockout'),
use: [
{
loader: 'expose-loader',
options: 'ko',
},
],
},
],
You can also use this configuration only for development mode.
cosmoKenney commented
Thanks. I've moved to Angular so this is no longer an issue for me.