├── tsconfig.json ├── src ├── module.ts └── plugin.json ├── README.md ├── .gitignore ├── dist ├── plugin.json └── module.js ├── package.json └── webpack.config.js /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strictNullChecks": true, 4 | "module": "none", 5 | "target": "es6", 6 | "rootDir": "./src" 7 | }, 8 | "include": [ 9 | "./src/**/*.ts" 10 | ] 11 | } -------------------------------------------------------------------------------- /src/module.ts: -------------------------------------------------------------------------------- 1 | import { PanelCtrl } from 'grafana/app/plugins/sdk'; 2 | 3 | class Ctrl extends PanelCtrl { 4 | 5 | static template: string = "
Hello from TypeScript Template Plugin
"; 6 | 7 | constructor($scope, $injector) { 8 | super($scope, $injector); 9 | } 10 | 11 | link(scope, element) { 12 | } 13 | 14 | } 15 | 16 | export { Ctrl as PanelCtrl } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Webpack Template for Grafana plugins development 2 | 3 | 4 | 5 | Grafana [plugin](http://docs.grafana.org/plugins/developing/development/) 6 | [webpack](https://webpack.github.io) & [TypeScript](https://github.com/Microsoft/TypeScript) version 7 | 8 | Based on [grafana-plugin-template-webpack](https://github.com/CorpGlory/grafana-plugin-template-webpack) and [@types/grafana](https://github.com/CorpGlory/types-grafana) 9 | 10 | # Build 11 | 12 | ``` 13 | npm install 14 | npm run build 15 | ``` 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | coverage/ 4 | .aws-config.json 5 | awsconfig 6 | /emails/dist 7 | /public_gen 8 | /tmp 9 | vendor/phantomjs/phantomjs 10 | 11 | docs/AWS_S3_BUCKET 12 | docs/GIT_BRANCH 13 | docs/VERSION 14 | docs/GITCOMMIT 15 | docs/changed-files 16 | docs/changed-files 17 | 18 | # locally required config files 19 | public/css/*.min.css 20 | 21 | # Editor junk 22 | *.sublime-workspace 23 | *.swp 24 | .idea/ 25 | *.iml 26 | 27 | /data/* 28 | /bin/* 29 | 30 | conf/custom.ini 31 | fig.yml 32 | profile.cov 33 | grafana 34 | .notouch 35 | .DS_Store 36 | .tscache 37 | -------------------------------------------------------------------------------- /dist/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "panel", 3 | "name": "Plugin Template TypeScript Name", 4 | "id": "grafana-plugin-template-webpack-typescript", 5 | "info": { 6 | "description": "Plugin Template TypeScript Description", 7 | "author": { 8 | "name": "Author Name", 9 | "url": "https://github.com/CorpGlory/grafana-plugin-template-webpack-typescript" 10 | }, 11 | "keywords": [ ], 12 | "logos": { }, 13 | "links": [ ], 14 | "screenshots": [ ], 15 | "version": "0.0.1", 16 | "updated": "2017-09-16" 17 | }, 18 | "dependencies": { 19 | "grafanaVersion": "4.1.1", 20 | "plugins": [ ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "panel", 3 | "name": "Plugin Template TypeScript Name", 4 | "id": "grafana-plugin-template-webpack-typescript", 5 | "info": { 6 | "description": "Plugin Template TypeScript Description", 7 | "author": { 8 | "name": "Author Name", 9 | "url": "https://github.com/CorpGlory/grafana-plugin-template-webpack-typescript" 10 | }, 11 | "keywords": [ ], 12 | "logos": { }, 13 | "links": [ ], 14 | "screenshots": [ ], 15 | "version": "0.0.1", 16 | "updated": "2017-09-16" 17 | }, 18 | "dependencies": { 19 | "grafanaVersion": "4.1.1", 20 | "plugins": [ ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grafana-plugin-template-webpack-typescript", 3 | "version": "1.0.0", 4 | "description": "Some description", 5 | "main": "dist/module", 6 | "scripts": { 7 | "build": "webpack" 8 | }, 9 | "keywords": [], 10 | "author": "Alexey Velikiy", 11 | "license": "MIT", 12 | "repository": "https://github.com/CorpGlory/grafana-plugin-template-webpack-typescript", 13 | "devDependencies": { 14 | "@types/grafana": "git+https://git@github.com/CorpGlory/types-grafana.git", 15 | "babel-core": "^6.26.0", 16 | "babel-loader": "^7.1.2", 17 | "babel-preset-env": "^1.6.0", 18 | "copy-webpack-plugin": "^4.0.1", 19 | "loader-utils": "^1.1.0", 20 | "webpack": "^3.6.0", 21 | "ts-loader": "^2.3.7", 22 | "typescript": "^2.4.2" 23 | }, 24 | "dependencies": {} 25 | } 26 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 4 | 5 | 6 | module.exports = { 7 | target: 'node', 8 | context: __dirname + "/src", 9 | entry: './module.ts', 10 | output: { 11 | filename: "module.js", 12 | path: path.resolve(__dirname, 'dist'), 13 | libraryTarget: "amd" 14 | }, 15 | externals: [ 16 | // remove the line below if you don't want to use buildin versions 17 | 'jquery', 'lodash', 'moment', 18 | function(context, request, callback) { 19 | var prefix = 'grafana/'; 20 | if (request.indexOf(prefix) === 0) { 21 | return callback(null, request.substr(prefix.length)); 22 | } 23 | callback(); 24 | } 25 | ], 26 | plugins: [ 27 | new webpack.optimize.OccurrenceOrderPlugin(), 28 | new CopyWebpackPlugin([ 29 | { from: 'plugin.json' }, 30 | ]) 31 | ], 32 | resolve: { 33 | extensions: [".ts", ".js"] 34 | }, 35 | module: { 36 | rules: [ 37 | { 38 | test: /\.tsx?$/, 39 | loaders: [ 40 | { 41 | loader: "babel-loader", 42 | options: { presets: ['env'] } 43 | }, 44 | "ts-loader" 45 | ], 46 | exclude: /node_modules/, 47 | } 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /dist/module.js: -------------------------------------------------------------------------------- 1 | define(["app/plugins/sdk"], function(__WEBPACK_EXTERNAL_MODULE_1__) { return /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { 40 | /******/ configurable: false, 41 | /******/ enumerable: true, 42 | /******/ get: getter 43 | /******/ }); 44 | /******/ } 45 | /******/ }; 46 | /******/ 47 | /******/ // getDefaultExport function for compatibility with non-harmony modules 48 | /******/ __webpack_require__.n = function(module) { 49 | /******/ var getter = module && module.__esModule ? 50 | /******/ function getDefault() { return module['default']; } : 51 | /******/ function getModuleExports() { return module; }; 52 | /******/ __webpack_require__.d(getter, 'a', getter); 53 | /******/ return getter; 54 | /******/ }; 55 | /******/ 56 | /******/ // Object.prototype.hasOwnProperty.call 57 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58 | /******/ 59 | /******/ // __webpack_public_path__ 60 | /******/ __webpack_require__.p = ""; 61 | /******/ 62 | /******/ // Load entry module and return exports 63 | /******/ return __webpack_require__(__webpack_require__.s = 0); 64 | /******/ }) 65 | /************************************************************************/ 66 | /******/ ([ 67 | /* 0 */ 68 | /***/ (function(module, exports, __webpack_require__) { 69 | 70 | "use strict"; 71 | 72 | 73 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 74 | 75 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 76 | 77 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 78 | 79 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 80 | 81 | Object.defineProperty(exports, "__esModule", { value: true }); 82 | var sdk_1 = __webpack_require__(1); 83 | 84 | var Ctrl = function (_sdk_1$PanelCtrl) { 85 | _inherits(Ctrl, _sdk_1$PanelCtrl); 86 | 87 | function Ctrl($scope, $injector) { 88 | _classCallCheck(this, Ctrl); 89 | 90 | return _possibleConstructorReturn(this, (Ctrl.__proto__ || Object.getPrototypeOf(Ctrl)).call(this, $scope, $injector)); 91 | } 92 | 93 | _createClass(Ctrl, [{ 94 | key: "link", 95 | value: function link(scope, element) {} 96 | }]); 97 | 98 | return Ctrl; 99 | }(sdk_1.PanelCtrl); 100 | 101 | Ctrl.template = "
Hello from TypeScript Template Plugin
"; 102 | exports.PanelCtrl = Ctrl; 103 | 104 | /***/ }), 105 | /* 1 */ 106 | /***/ (function(module, exports) { 107 | 108 | module.exports = __WEBPACK_EXTERNAL_MODULE_1__; 109 | 110 | /***/ }) 111 | /******/ ])});; --------------------------------------------------------------------------------