webpack.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const path = require('path')
  2. module.exports = {
  3. // Defines the "entry point(s)" for the application - i.e. the file which
  4. // bootstraps the application
  5. entry: {
  6. richText: './public/es/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/es'),
  13. filename: '[name].js',
  14. // Output as UMD bundle (allows main JS to import with CJS, AMD or global
  15. // style code bundles
  16. libraryTarget: 'umd',
  17. // Name the exported variable from output bundle
  18. library: ['Frontend', '[name]']
  19. },
  20. // TODO??
  21. // Defines the external modules which will be stripped out when bundling for
  22. // the main app. These modules are already loaded in the main app environment,
  23. // so we strip them out to prevent conflicts.
  24. // externals: {},
  25. // Define how file types are handled by webpack
  26. module: {
  27. rules: [{
  28. // Pass application JS files through babel-loader, compiling to ES5
  29. test: /\.js$/,
  30. // Only compile application files (dependencies are in ES5 already)
  31. exclude: /node_modules/,
  32. use: [{
  33. loader: 'babel-loader',
  34. options: {
  35. presets: [
  36. ['env', { modules: false }]
  37. ],
  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. }