webpack.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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$/, // Only compile .js files
  30. // Only compile application files (dependencies are in ES5 already)
  31. // include: [path.join(__dirname, './public/frontend')],
  32. exclude: /node_modules/,
  33. use: [{
  34. loader: 'babel-loader',
  35. options: {
  36. presets: ['env'],
  37. // Configure babel-loader to cache compiled output so that subsequent
  38. // compile runs are much faster
  39. cacheDirectory: true
  40. }
  41. }]
  42. }]
  43. },
  44. // TODO
  45. // plugins: {}
  46. }