development.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use strict';
  2. /**
  3. * Config responsible for building Handsontable `dist/` files:
  4. * - handsontable.js
  5. * - handsontable.css
  6. * - handsontable.full.js
  7. * - handsontable.full.css
  8. */
  9. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  10. const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
  11. const path = require('path');
  12. const webpack = require('webpack');
  13. const configFactory = require('./base');
  14. const PACKAGE_FILENAME = process.env.HOT_FILENAME;
  15. module.exports.create = function create(envArgs) {
  16. const configBase = configFactory.create(envArgs);
  17. const configFull = configFactory.create(envArgs);
  18. configBase.forEach(function(c) {
  19. c.output.filename = PACKAGE_FILENAME + '.js';
  20. c.devtool = 'source-map';
  21. // Exclude all external dependencies from 'base' bundle (handsontable.js and handsontable.css files)
  22. c.externals = {
  23. numbro: {
  24. root: 'numbro',
  25. commonjs2: 'numbro',
  26. commonjs: 'numbro',
  27. amd: 'numbro',
  28. },
  29. moment: {
  30. root: 'moment',
  31. commonjs2: 'moment',
  32. commonjs: 'moment',
  33. amd: 'moment',
  34. },
  35. pikaday: {
  36. root: 'Pikaday',
  37. commonjs2: 'pikaday',
  38. commonjs: 'pikaday',
  39. amd: 'pikaday',
  40. }
  41. };
  42. c.module.rules.unshift({
  43. test: [
  44. // Disable loading css files from pikaday module
  45. /pikaday\/css/,
  46. ],
  47. loader: path.resolve(__dirname, 'loader/empty-loader.js'),
  48. });
  49. c.plugins.push(
  50. new ExtractTextPlugin(PACKAGE_FILENAME + '.css')
  51. );
  52. });
  53. configFull.forEach(function(c) {
  54. c.output.filename = PACKAGE_FILENAME + '.full.js';
  55. c.module.rules.unshift({
  56. test: /numbro/,
  57. use: [
  58. {
  59. loader: path.resolve(__dirname, 'loader/exports-to-window-loader.js'),
  60. options: {
  61. numbro: 'numbro',
  62. }
  63. }
  64. ]
  65. });
  66. c.module.rules.unshift({
  67. test: /moment/,
  68. use: [
  69. {
  70. loader: path.resolve(__dirname, 'loader/exports-to-window-loader.js'),
  71. options: {
  72. moment: 'moment',
  73. }
  74. }
  75. ]
  76. });
  77. c.plugins.push(
  78. new ExtractTextPlugin(PACKAGE_FILENAME + '.full.css')
  79. );
  80. });
  81. return [].concat(configBase, configFull);
  82. }