webpack.prod.js 1.6 KB

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