- install npm
- in your terminal,
cd path-to-your-project-folder
thennpm init -y
- it’ll auto-generate “package.json” in root folder
- install a bunch of packages
- it’ll auto-generate a folder “node_modules” and a file “package-lock.json” in root folder once you start install packages
npm install webpack --save-dev
npm install webpack-cli --save-dev
npm install webpack-dev-server --save-dev
npm install typescript --save-dev
npm install ts-loader --save-dev
npm install style-loader --save-dev
npm install css-loader --save-dev
npm install sass-loader --save-dev
npm install sass --save-dev
npm install terser-webpack-plugin --save-dev
npm install ts-node --save-dev
npm install d3 --save
-
create folder structure as below and create a few files in it
- my-project
- src
- common
- types.ts
- utils.ts
- visualizations
- myTemplace.ts
- common
- src
- package.json
- tsconfig.json
- webpack.config.js
- my-project
-
add two lines in package.json in “script” section
"build": "webpack”
"start:dev": "webpack-dev-server"
-
run “npm run build” to create output .js file in ./dist
-
run “npm run start:dev” to start local server
- if you set up successfully, once you run it, you should see a local server webpage pop up
- to test it, you can do localhost:3443/myTemplate.js to see the generated js script
-
add the local file reference to Looker
- Navigate to the Admin page in Looker
- Select Visualizations from the left nav
- Select the Add visualization button
- Fill out the form
ExampleID: my-custom-viz-dev Label: My Custom Visualization - DevelopmentMain: https://localhost:3443/myTemplate.js
- Select Save
- Create or go to an Explore and you should see the custom visualization in the menu. select it.
- Add some data so your explore has some data
- Start your local webserver by running the
npm script start:dev