2
0

webpack.common.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const webpack = require('webpack');
  2. const helpers = require('./helpers');
  3. /*
  4. * Webpack Plugins
  5. */
  6. // problem with copy-webpack-plugin
  7. const AssetsPlugin = require('assets-webpack-plugin');
  8. const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
  9. /*
  10. * Webpack Constants
  11. */
  12. const HMR = helpers.hasProcessFlag('hot');
  13. /*
  14. * Webpack configuration
  15. *
  16. * See: http://webpack.github.io/docs/configuration.html#cli
  17. */
  18. module.exports = function (options) {
  19. isProd = options.env === 'production';
  20. return {
  21. entry: {
  22. 'app': './resource/js/app',
  23. 'legacy': './resource/js/legacy/crowi',
  24. 'legacy-form': './resource/js/legacy/crowi-form',
  25. 'legacy-admin': './resource/js/legacy/crowi-admin',
  26. 'legacy-presentation': './resource/js/legacy/crowi-presentation',
  27. 'plugin': './resource/js/plugin.js',
  28. },
  29. resolve: {
  30. extensions: ['.js', '.json'],
  31. modules: [helpers.root('src'), helpers.root('node_modules')],
  32. },
  33. module: {
  34. rules: [
  35. {
  36. test: /.jsx?$/,
  37. exclude: /node_modules/,
  38. use: [{
  39. loader: 'babel-loader?cacheDirectory',
  40. }]
  41. },
  42. {
  43. test: /\.json$/,
  44. use: 'json-loader',
  45. },
  46. /*
  47. * File loader for supporting images, for example, in CSS files.
  48. */
  49. {
  50. test: /\.(jpg|png|gif)$/,
  51. use: 'file-loader',
  52. },
  53. /* File loader for supporting fonts, for example, in CSS files.
  54. */
  55. {
  56. test: /\.(eot|woff2?|svg|ttf)([\?]?.*)$/,
  57. use: 'file-loader',
  58. }
  59. ]
  60. },
  61. plugins: [
  62. new AssetsPlugin({
  63. path: helpers.root('public/js'),
  64. filename: 'webpack-assets.json',
  65. prettyPrint: true,
  66. }),
  67. new CommonsChunkPlugin({
  68. name: 'commons',
  69. minChunks: module => /node_modules/.test(module.resource),
  70. }),
  71. new webpack.ProvidePlugin({
  72. jQuery: "jquery",
  73. $: "jquery",
  74. }),
  75. ]
  76. };
  77. }