webpack.common.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. var path = require('path')
  2. var HtmlWebpackPlugin = require('html-webpack-plugin')
  3. var webpack = require('webpack')
  4. module.exports = {
  5. entry: {
  6. opensheetmusicdisplay: './src/index.ts', // Main index (OpenSheetMusicDisplay and other classes)
  7. demo: './demo/index.js' // Demo index
  8. },
  9. output: {
  10. path: path.resolve(__dirname, 'build'),
  11. filename: '[name].js',
  12. library: 'opensheetmusicdisplay',
  13. libraryTarget: 'umd',
  14. globalObject: 'this'
  15. },
  16. resolve: {
  17. alias: {
  18. handlebars: 'handlebars/dist/handlebars.min.js'
  19. },
  20. // Add '.ts' and '.tsx' as a resolvable extension.
  21. extensions: ['.ts', '.tsx', '.js'],
  22. },
  23. module: {
  24. rules: [
  25. // all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
  26. {
  27. test: /\.ts$/,
  28. loader: 'ts-loader',
  29. // loader: 'awesome-typescript-loader',
  30. exclude: /(node_modules|bower_components)/
  31. },
  32. // all html files will be handled by html-loader
  33. {
  34. test: /\.html$/i,
  35. loader: 'html-loader',
  36. exclude: /(node_modules|bower_components|demo|build|bin)/
  37. },
  38. {
  39. test: /\.json5$/i,
  40. loader: 'json5-loader',
  41. type: 'javascript/auto',
  42. exclude: /(node_modules|bower_components|demo|build|bin)/
  43. }
  44. ]
  45. },
  46. plugins: [
  47. new webpack.ProvidePlugin({
  48. $: 'jquery',
  49. jQuery: 'jquery'
  50. }),
  51. new webpack.EnvironmentPlugin({
  52. STATIC_FILES_SUBFOLDER: false, // Set to other directory if NOT using webpack-dev-server
  53. DEBUG: false,
  54. DRAW_BOUNDING_BOX_ELEMENT: false // Specifies the element to draw bounding boxes for (e.g. 'GraphicalLabels'). If 'all', bounding boxes are drawn for all elements.
  55. }),
  56. // add a demo page to the build folder
  57. new HtmlWebpackPlugin({
  58. template: 'demo/index.html',
  59. favicon: 'demo/favicon.ico',
  60. title: 'OpenSheetMusicDisplay Demo'
  61. })
  62. ],
  63. devServer: {
  64. static: [
  65. path.join(__dirname, 'test/data'),
  66. path.join(__dirname, 'build'),
  67. path.join(__dirname, 'demo')
  68. ],
  69. port: 8000,
  70. compress: false
  71. }
  72. }