# Cesium + Webpack + Ts

**URL:** <https://community.cesium.com/t/cesium-webpack-ts/6425>\
**Category:** CesiumJS\
**Created:** [January 3, 2018, 12:59am UTC](https://community.cesium.com/t/cesium-webpack-ts/6425 "2018-01-03T00:59:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilist1000](https://avatars.discourse-cdn.com/v4/letter/i/ccd318/32.png) [@ilist1000](https://community.cesium.com/u/ilist1000)\
**Post date:** [January 3, 2018, 12:59am UTC](https://community.cesium.com/t/cesium-webpack-ts/6425/1 "2018-01-03T00:59:57Z")

</div>

1. A concise explanation of the problem you're experiencing.

I have tried to add typescript support to the offical Webpack repo of Cesium. ([https://github.com/AnalyticalGraphicsInc/cesium-webpack-example](https://github.com/AnalyticalGraphicsInc/cesium-webpack-example))  
I just can't get it to work with the ts definitions found here: [https://libraries.io/npm/cesium-typings](https://libraries.io/npm/cesium-typings)  
It compiles just fine, but an error is produced in the browser: "ReferenceError: Cesium is not defined"  
I don't know how to use the definitions.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

/// \<reference path="typings.d.ts" /\>  
require("cesium/Cesium")  
require('cesium/Widgets/widgets.css');  
// Example app  
var viewer = new Cesium.Viewer('cesiumContainer');

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I want to use webpack with cesium and typescript.

4. The Cesium version you're using, your operating system and browser.

OS: Fedora 27  
Browser: Firefox 57.0.1

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [January 3, 2018, 8:42pm UTC](https://community.cesium.com/t/cesium-webpack-ts/6425/2 "2018-01-03T20:42:49Z")

</div>

Hi there,

Importing Cesium.js in webpack does not define the **Cesium** variable globally.

var Cesium = require(“cesium/Cesium”);

``

That should resolve your reference error, but may be incompatible with how you are including the .ts file. I don’t have experience adding it to webpack with Cesium, but there is a [TypeScript loader](https://webpack.js.org/guides/typescript/) available along with some useful documentation, which I would try. Let us know if you have any success! I’m sure others would like to use the same configuration.

Thanks,

Gabby
