webpack.prod.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. 'use strict';
  2. const merge = require('webpack-merge');
  3. const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
  4. const common = require('./webpack.common.js');
  5. const webpack = require('webpack');
  6. const path = require('path');
  7. const ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
  8. const HtmlWebpackPlugin = require("html-webpack-plugin");
  9. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  10. module.exports = merge(common, {
  11. devtool: "source-map",
  12. entry: {
  13. dark: './public/sass/grafana.dark.scss',
  14. light: './public/sass/grafana.light.scss',
  15. vendor: require('./dependencies'),
  16. },
  17. module: {
  18. rules: [
  19. {
  20. test: /\.tsx?$/,
  21. enforce: 'pre',
  22. exclude: /node_modules/,
  23. use: {
  24. loader: 'tslint-loader',
  25. options: {
  26. emitErrors: true,
  27. typeCheck: false,
  28. }
  29. }
  30. },
  31. {
  32. test: /\.tsx?$/,
  33. exclude: /node_modules/,
  34. use: [
  35. {
  36. loader: 'awesome-typescript-loader',
  37. options: {
  38. errorsAsWarnings: false,
  39. },
  40. },
  41. ]
  42. },
  43. require('./sass.rule.js')({
  44. sourceMap: false, minimize: true, preserveUrl: false
  45. })
  46. ]
  47. },
  48. devServer: {
  49. noInfo: true,
  50. stats: {
  51. chunks: false,
  52. },
  53. },
  54. plugins: [
  55. new ExtractTextPlugin({
  56. filename: 'grafana.[name].css',
  57. }),
  58. new ngAnnotatePlugin(),
  59. new UglifyJSPlugin({
  60. sourceMap: true,
  61. }),
  62. new webpack.DefinePlugin({
  63. 'process.env': {
  64. 'NODE_ENV': JSON.stringify('production')
  65. }
  66. }),
  67. new HtmlWebpackPlugin({
  68. filename: path.resolve(__dirname, '../../public/views/index.html'),
  69. template: path.resolve(__dirname, '../../public/views/index.template.html'),
  70. inject: 'body',
  71. chunks: ['manifest', 'vendor', 'app'],
  72. }),
  73. new webpack.optimize.CommonsChunkPlugin({
  74. names: ['vendor', 'manifest'],
  75. }),
  76. function () {
  77. this.plugin("done", function (stats) {
  78. if (stats.compilation.errors && stats.compilation.errors.length) {
  79. console.log(stats.compilation.errors);
  80. process.exit(1);
  81. }
  82. });
  83. }
  84. ]
  85. });