webpack.prod.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. require('./sass.rule.js')({
  20. sourceMap: false, minimize: true
  21. })
  22. ]
  23. },
  24. devServer: {
  25. noInfo: true,
  26. stats: {
  27. chunks: false,
  28. },
  29. },
  30. plugins: [
  31. new ExtractTextPlugin({
  32. filename: 'grafana.[name].css',
  33. }),
  34. new ngAnnotatePlugin(),
  35. new UglifyJSPlugin({
  36. sourceMap: true,
  37. }),
  38. new webpack.DefinePlugin({
  39. 'process.env': {
  40. 'NODE_ENV': JSON.stringify('production')
  41. }
  42. }),
  43. new HtmlWebpackPlugin({
  44. filename: path.resolve(__dirname, '../../public/views/index.html'),
  45. template: path.resolve(__dirname, '../../public/views/index.template.html'),
  46. inject: 'body',
  47. chunks: ['manifest', 'vendor', 'app'],
  48. }),
  49. new webpack.optimize.CommonsChunkPlugin({
  50. names: ['vendor', 'manifest'],
  51. }),
  52. function() {
  53. this.plugin("done", function(stats) {
  54. if (stats.compilation.errors && stats.compilation.errors.length) {
  55. console.log(stats.compilation.errors);
  56. process.exit(1);
  57. }
  58. });
  59. }
  60. ]
  61. });