webpack.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var webpack = require('webpack');
  2. const package = require('./package.json');
  3. const path = require('path');
  4. module.exports = env => {
  5. if(env && env.NODE_ENV === "test") {
  6. return [
  7. {
  8. entry: './test/spec/webpack/importSpec.src.js',
  9. mode: 'production',
  10. output: {
  11. path: path.resolve(__dirname, 'test/spec/webpack'),
  12. filename: 'importSpec.build.js'
  13. },
  14. target: 'node',
  15. resolve: {
  16. extensions: ['.js']
  17. }
  18. }
  19. ];
  20. }
  21. else {
  22. return [
  23. {
  24. entry: './index.js',
  25. mode: 'production',
  26. optimization: {
  27. minimize: false
  28. },
  29. output: {
  30. filename: 'fast-json-patch.js',
  31. library: 'jsonpatch',
  32. libraryTarget: 'var'
  33. },
  34. resolve: {
  35. extensions: ['.js']
  36. },
  37. plugins: [
  38. new webpack.BannerPlugin('fast-json-patch, version: ' + package['version'])
  39. ]
  40. },
  41. {
  42. entry: './index.js',
  43. mode: 'production',
  44. output: {
  45. filename: 'fast-json-patch.min.js',
  46. library: 'jsonpatch',
  47. libraryTarget: 'var'
  48. },
  49. resolve: {
  50. extensions: ['.js']
  51. },
  52. plugins: [
  53. new webpack.BannerPlugin('fast-json-patch, version: ' + package['version'])
  54. ]
  55. }
  56. ];
  57. }
  58. };