webpack.config.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const path = require('path')
  2. module.exports = {
  3. // Defines the "entry point" for the application - i.e. the file which
  4. // bootstraps the application
  5. entry: {
  6. 'rich-text': './public/frontend/rich-text.js'
  7. },
  8. // Define where and how the bundle will be output to disk
  9. // Note: webpack-dev-server does not write the bundle to disk, instead it is
  10. // kept in memory for speed
  11. output: {
  12. path: path.join(__dirname, '/public/js/frontend'),
  13. // publicPath: '/frontend/',
  14. filename: '[name].js',
  15. // Output as UMD bundle (allows main JS to import with CJS, AMD or global
  16. // style code bundles
  17. libraryTarget: 'umd',
  18. // Name the exported variable from output bundle
  19. library: ['Frontend', '[name]']
  20. },
  21. // TODO??
  22. // Defines the external modules which will be stripped out when bundling for
  23. // the rails app. These modules are already loaded in the rails app
  24. // environment, so we strip them out to prevent conflicts.
  25. // externals: {},
  26. // Define how file types are handled by webpack
  27. module: {
  28. rules: [{
  29. // Pass application JS files through babel-loader, compiling to ES5
  30. test: /\.js$/, // Only compile .js files
  31. // Only compile application files (dependencies are in ES5 already)
  32. // include: [path.join(__dirname, './public/frontend')],
  33. exclude: /node_modules/,
  34. use: [{
  35. loader: 'babel-loader',
  36. options: {
  37. presets: ['env'],
  38. // Configure babel-loader to cache compiled output so that subsequent
  39. // compile runs are much faster
  40. cacheDirectory: true
  41. }
  42. }]
  43. }]
  44. },
  45. // TODO
  46. // plugins: {}
  47. }