webpack.prod.js 1.6 KB

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