Open bbottema opened 8 years ago
any workaround or ng2-prism alternative?
@Shoocky I'm requiring the library distribution using webpack manually (instead of importing it from the source files), which I acquired from Prism's download builder. Then using Angular's AfterViewChecked
lifecycle event I use the global Prism reference (unfortunately).
In the .ts file where I need it:
declare var Prism:any;
require('./lib/prism.ts');
export class YourApp implements AfterViewChecked {
ngAfterViewChecked():any {
return Prism.highlightAll();
}
}
Then to prevent it from being included in my own bundle:
In external.ts (for any other libraries I need to bootstrap this way):
require('./app/lib/prism.ts');
In webpack.config.js:
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'external': './src/external.ts',
'app': './src/app.ts'
}
Also include in the CommonsChunkPlugin
entry of webpack.config.js.
ng2-prism still uses old classes from Angular2 since rc1, causing https://github.com/angular/angular2-seed/issues/79.