Gruntfile.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const {
  2. CheckerPlugin,
  3. TsConfigPathsPlugin
  4. } = require('awesome-typescript-loader');
  5. const LiveReloadPlugin = require('webpack-livereload-plugin');
  6. const path = require('path');
  7. module.exports = function(grunt) {
  8. var packageData = grunt.file.readJSON('package.json');
  9. const tsDemoSourceFile = path.resolve('src/demo/ts/Demo.ts');
  10. const jsDemoDestFile = path.resolve('scratch/compiled/demo.js');
  11. grunt.initConfig({
  12. pkg: packageData,
  13. shell: {
  14. command: 'tsc'
  15. },
  16. webpack: {
  17. options: {
  18. mode: 'development',
  19. watch: true
  20. },
  21. dev: {
  22. entry: tsDemoSourceFile,
  23. mode: 'development',
  24. devtool: 'source-map',
  25. resolve: {
  26. extensions: ['.ts', '.js'],
  27. plugins: [
  28. new TsConfigPathsPlugin({
  29. compiler: 'typescript'
  30. })
  31. ]
  32. },
  33. module: {
  34. rules: [
  35. {
  36. test: /\.ts$/,
  37. use: [
  38. {
  39. loader: 'awesome-typescript-loader'
  40. }
  41. ]
  42. }
  43. ]
  44. },
  45. plugins: [new LiveReloadPlugin(), new CheckerPlugin()],
  46. output: {
  47. filename: path.basename(jsDemoDestFile),
  48. path: path.dirname(jsDemoDestFile)
  49. }
  50. }
  51. }
  52. });
  53. require('load-grunt-tasks')(grunt);
  54. grunt.registerTask('default', []);
  55. };