webpack.plugin.config.js 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. var path = require('path');
  2. var webpack = require('webpack');
  3. var ManifestPlugin = require('webpack-manifest-plugin');
  4. var config = {
  5. entry: {
  6. plugin: './plugin/plugin.js',
  7. },
  8. output: {
  9. path: path.join(__dirname + "/public/js"),
  10. filename: "[name].[hash].js"
  11. },
  12. resolve: {
  13. modulesDirectories: [
  14. './node_modules', './plugin/node_modules',
  15. ],
  16. },
  17. module: {
  18. loaders: [
  19. {
  20. test: /.jsx?$/,
  21. loader: 'babel-loader',
  22. query: {
  23. presets: ['es2015', 'react']
  24. }
  25. }
  26. ]
  27. },
  28. plugins: []
  29. };
  30. if (process.env && process.env.NODE_ENV !== 'development') {
  31. config.plugins = [
  32. new webpack.DefinePlugin({
  33. 'process.env':{
  34. 'NODE_ENV': JSON.stringify('production')
  35. }
  36. }),
  37. new webpack.optimize.UglifyJsPlugin({
  38. compress:{
  39. warnings: false
  40. }
  41. }),
  42. ];
  43. }
  44. config.plugins.push(new ManifestPlugin({
  45. fileName: 'manifest-plugin.json'
  46. }));
  47. module.exports = config;