webpack.plugin.config.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. exclude: /node_modules/,
  23. query: {
  24. presets: ['es2015', 'react']
  25. }
  26. }
  27. ]
  28. },
  29. plugins: []
  30. };
  31. if (process.env && process.env.NODE_ENV !== 'development') {
  32. config.plugins = [
  33. new webpack.DefinePlugin({
  34. 'process.env':{
  35. 'NODE_ENV': JSON.stringify('production')
  36. }
  37. }),
  38. new webpack.optimize.UglifyJsPlugin({
  39. compress:{
  40. warnings: false
  41. }
  42. }),
  43. ];
  44. }
  45. config.plugins.push(new ManifestPlugin({
  46. fileName: 'manifest-plugin.json'
  47. }));
  48. module.exports = config;