webpack.config.npm.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * Licensed to Cloudera, Inc. under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. Cloudera, Inc. licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. const path = require('path');
  19. const { VueLoaderPlugin } = require('vue-loader');
  20. const CleanWebpackPlugin = require('clean-webpack-plugin');
  21. const CopyWebpackPlugin = require('copy-webpack-plugin');
  22. const DIST_DIR = path.join(__dirname, 'npm_dist');
  23. const JS_ROOT = path.join(__dirname, '/desktop/core/src/desktop/js');
  24. const defaultConfig = Object.assign({}, require('./webpack.config'), {
  25. mode: 'production',
  26. optimization: {
  27. minimize: true
  28. },
  29. plugins: []
  30. });
  31. const npmSetupPlugins = [
  32. new CleanWebpackPlugin([DIST_DIR]),
  33. new CopyWebpackPlugin({
  34. patterns: [
  35. { from: './package.json', to: `${DIST_DIR}/package.json` },
  36. { from: './NPM-README.md', to: `${DIST_DIR}/README.md` },
  37. { from: JS_ROOT, to: `${DIST_DIR}/src` }
  38. ]
  39. })
  40. ];
  41. const libConfig = Object.assign({}, defaultConfig, {
  42. entry: {
  43. executor: [`${JS_ROOT}/apps/editor/execution/executor.ts`]
  44. },
  45. output: {
  46. path: `${DIST_DIR}/lib/`
  47. }
  48. });
  49. const webComponentsConfig = Object.assign({}, defaultConfig, {
  50. entry: {
  51. 'er-diagram': [`${JS_ROOT}/components/er-diagram/webcomp.ts`],
  52. 'query-editor-components': [`${JS_ROOT}/apps/editor/components/QueryEditorWebComponent.ts`]
  53. },
  54. output: {
  55. path: `${DIST_DIR}/lib/components`
  56. },
  57. plugins: npmSetupPlugins.concat(new VueLoaderPlugin())
  58. });
  59. const parserConfig = Object.assign({}, defaultConfig, {
  60. entry: {
  61. calciteAutocompleteParser: [`${JS_ROOT}/parse/sql/calcite/calciteAutocompleteParser.js`],
  62. calciteSyntaxParser: [`${JS_ROOT}/parse/sql/calcite/calciteSyntaxParser.js`],
  63. druidAutocompleteParser: [`${JS_ROOT}/parse/sql/druid/druidAutocompleteParser.js`],
  64. druidSyntaxParser: [`${JS_ROOT}/parse/sql/druid/druidSyntaxParser.js`],
  65. elasticsearchAutocompleteParser: [
  66. `${JS_ROOT}/parse/sql/elasticsearch/elasticsearchAutocompleteParser.js`
  67. ],
  68. elasticsearchSyntaxParser: [`${JS_ROOT}/parse/sql/elasticsearch/elasticsearchSyntaxParser.js`],
  69. flinkAutocompleteParser: [`${JS_ROOT}/parse/sql/flink/flinkAutocompleteParser.js`],
  70. flinkSyntaxParser: [`${JS_ROOT}/parse/sql/flink/flinkSyntaxParser.js`],
  71. genericAutocompleteParser: [`${JS_ROOT}/parse/sql/generic/genericAutocompleteParser.js`],
  72. genericSyntaxParser: [`${JS_ROOT}/parse/sql/generic/genericSyntaxParser.js`],
  73. hiveAutocompleteParser: [`${JS_ROOT}/parse/sql/hive/hiveAutocompleteParser.js`],
  74. hiveSyntaxParser: [`${JS_ROOT}/parse/sql/hive/hiveSyntaxParser.js`],
  75. impalaAutocompleteParser: [`${JS_ROOT}/parse/sql/impala/impalaAutocompleteParser.js`],
  76. impalaSyntaxParser: [`${JS_ROOT}/parse/sql/impala/impalaSyntaxParser.js`],
  77. ksqlAutocompleteParser: [`${JS_ROOT}/parse/sql/ksql/ksqlAutocompleteParser.js`],
  78. ksqlSyntaxParser: [`${JS_ROOT}/parse/sql/ksql/ksqlSyntaxParser.js`],
  79. phoenixAutocompleteParser: [`${JS_ROOT}/parse/sql/phoenix/phoenixAutocompleteParser.js`],
  80. phoenixSyntaxParser: [`${JS_ROOT}/parse/sql/phoenix/phoenixSyntaxParser.js`],
  81. prestoAutocompleteParser: [`${JS_ROOT}/parse/sql/presto/prestoAutocompleteParser.js`],
  82. prestoSyntaxParser: [`${JS_ROOT}/parse/sql/presto/prestoSyntaxParser.js`],
  83. dasksqlAutocompleteParser: [`${JS_ROOT}/parse/sql/dasksql/dasksqlAutocompleteParser.js`],
  84. dasksqlSyntaxParser: [`${JS_ROOT}/parse/sql/dasksql/dasksqlSyntaxParser.js`]
  85. },
  86. performance: {
  87. hints: false,
  88. maxEntrypointSize: 1500000,
  89. maxAssetSize: 1500000
  90. },
  91. output: {
  92. path: `${DIST_DIR}/lib/parsers`,
  93. library: '[name]',
  94. libraryExport: 'default',
  95. libraryTarget: 'umd',
  96. umdNamedDefine: true,
  97. globalObject: `(typeof self !== 'undefined' ? self : this)`
  98. }
  99. });
  100. module.exports = [libConfig, webComponentsConfig, parserConfig];