webpack.prod.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. { loader: "awesome-typescript-loader" }
  36. ]
  37. },
  38. require('./sass.rule.js')({
  39. sourceMap: false, minimize: true, preserveUrl: false
  40. })
  41. ]
  42. },
  43. devServer: {
  44. noInfo: true,
  45. stats: {
  46. chunks: false,
  47. },
  48. },
  49. plugins: [
  50. new ExtractTextPlugin({
  51. filename: 'grafana.[name].css',
  52. }),
  53. new ngAnnotatePlugin(),
  54. new UglifyJSPlugin({
  55. sourceMap: true,
  56. }),
  57. new webpack.DefinePlugin({
  58. 'process.env': {
  59. 'NODE_ENV': JSON.stringify('production')
  60. }
  61. }),
  62. new HtmlWebpackPlugin({
  63. filename: path.resolve(__dirname, '../../public/views/index.html'),
  64. template: path.resolve(__dirname, '../../public/views/index.template.html'),
  65. inject: 'body',
  66. chunks: ['manifest', 'vendor', 'app'],
  67. }),
  68. new webpack.optimize.CommonsChunkPlugin({
  69. names: ['vendor', 'manifest'],
  70. }),
  71. function () {
  72. this.plugin("done", function (stats) {
  73. if (stats.compilation.errors && stats.compilation.errors.length) {
  74. console.log(stats.compilation.errors);
  75. process.exit(1);
  76. }
  77. });
  78. }
  79. ]
  80. });