alex_h Posted March 23, 2020 Share Posted March 23, 2020 (edited) Hi, I've been using pixi for many years but previously always loaded pixi.min.js via a script tag in my index.html Now I need to set up a typescript project with pixi v5 installed from npm into my node modules, and using webpack (or possibly rollup ) as a module bundler. I'm using VSCode. I created a new project and ran npm init, installed typescript, wepback (+ typescript plugin), and pixi js. Added barebones tsconfig.json and webpack.config.js. I created a test entry.ts file that imports pixi and instantiates a sprite. All the documentation I have found by googling says that I should be able to import pixi like: import * as PIXI from 'pixi.js'; but this isn't working for me. VSCode complains 'Cannot find module 'pixi.js'. I see the actual folder in node_modules is called @pixi is that related to the problem? How should I be importing pixi in my typescript files? Edited March 23, 2020 by alex_h Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 23, 2020 Share Posted March 23, 2020 (edited) I honestly dont like webpack/rollup. I barely tolerate parsel. Its integration with typescript is awful. However, because people are moving there without realizing how it works internally, and because most of PixiJS team are using bundlers already, I provide those instructions. You need package `pixi.js` or `pixi.js-legacy` or you have to make your own bundle here: https://pixijs.io/customize/ (switch to bundler) If you have pixi plugins that'll be extra problem, because most of them dont support bundlers. https://github.com/pixijs/pixi-layers/blob/master/README.md#webpack-browserify-angular - that's how to do it. Add it in your first file or in bundle file if you have one. In general, situation will change when we move everything, including TS definitions to module approach. We are halfway there. Edited March 23, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 23, 2020 Share Posted March 23, 2020 Also, wiki is a third great place to look for help: https://github.com/pixijs/pixi.js/wiki/v5-Boilerplate First is examples, second is forum. Zero is pixi sources. I don't know why people miss wiki page. Quote Link to comment Share on other sites More sharing options...
alex_h Posted March 23, 2020 Author Share Posted March 23, 2020 Thanks Ivan, I'll try out the boiler plate off of the wiki ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.