webpack.config.npm.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 npmSetupConfig = {
  32. entry: {
  33. 'package.json': './package.json'
  34. },
  35. output: {
  36. path: DIST_DIR,
  37. filename: 'package.json'
  38. },
  39. plugins: [
  40. new CleanWebpackPlugin([DIST_DIR]),
  41. new CopyWebpackPlugin({
  42. patterns: [
  43. { from: './NPM-README.md', to: `${DIST_DIR}/README.md` },
  44. { from: `${JS_ROOT}/components`, to: `${DIST_DIR}/src/components` },
  45. { from: `${JS_ROOT}/utils/hueUtils.js`, to: `${DIST_DIR}/src/utils/hueUtils.js` },
  46. { from: `${JS_ROOT}/parse`, to: `${DIST_DIR}/src/parse` },
  47. { from: `${JS_ROOT}/sql`, to: `${DIST_DIR}/src/sql` }
  48. ]
  49. })
  50. ]
  51. };
  52. const webComponentsConfig = Object.assign({}, defaultConfig, {
  53. entry: {
  54. 'er-diagram': [`${JS_ROOT}/components/er-diagram/webcomp.ts`],
  55. },
  56. output: {
  57. path: `${DIST_DIR}/components`
  58. },
  59. plugins: [
  60. new VueLoaderPlugin()
  61. ]
  62. });
  63. const parserConf = Object.assign({}, defaultConfig, {
  64. entry: {
  65. 'calciteAutocompleteParser': [`${JS_ROOT}/parse/sql/calcite/calciteAutocompleteParser.js`],
  66. 'calciteSyntaxParser': [`${JS_ROOT}/parse/sql/calcite/calciteSyntaxParser.js`],
  67. 'druidAutocompleteParser': [`${JS_ROOT}/parse/sql/druid/druidAutocompleteParser.js`],
  68. 'druidSyntaxParser': [`${JS_ROOT}/parse/sql/druid/druidSyntaxParser.js`],
  69. 'elasticsearchAutocompleteParser': [`${JS_ROOT}/parse/sql/elasticsearch/elasticsearchAutocompleteParser.js`],
  70. 'elasticsearchSyntaxParser': [`${JS_ROOT}/parse/sql/elasticsearch/elasticsearchSyntaxParser.js`],
  71. 'flinkAutocompleteParser': [`${JS_ROOT}/parse/sql/flink/flinkAutocompleteParser.js`],
  72. 'flinkSyntaxParser': [`${JS_ROOT}/parse/sql/flink/flinkSyntaxParser.js`],
  73. 'genericAutocompleteParser': [`${JS_ROOT}/parse/sql/generic/genericAutocompleteParser.js`],
  74. 'genericSyntaxParser': [`${JS_ROOT}/parse/sql/generic/genericSyntaxParser.js`],
  75. 'hiveAutocompleteParser': [`${JS_ROOT}/parse/sql/hive/hiveAutocompleteParser.js`],
  76. 'hiveSyntaxParser': [`${JS_ROOT}/parse/sql/hive/hiveSyntaxParser.js`],
  77. 'impalaAutocompleteParser': [`${JS_ROOT}/parse/sql/impala/impalaAutocompleteParser.js`],
  78. 'impalaSyntaxParser': [`${JS_ROOT}/parse/sql/impala/impalaSyntaxParser.js`],
  79. 'ksqlAutocompleteParser': [`${JS_ROOT}/parse/sql/ksql/ksqlAutocompleteParser.js`],
  80. 'ksqlSyntaxParser': [`${JS_ROOT}/parse/sql/ksql/ksqlSyntaxParser.js`],
  81. 'phoenixAutocompleteParser': [`${JS_ROOT}/parse/sql/phoenix/phoenixAutocompleteParser.js`],
  82. 'phoenixSyntaxParser': [`${JS_ROOT}/parse/sql/phoenix/phoenixSyntaxParser.js`],
  83. 'prestoAutocompleteParser': [`${JS_ROOT}/parse/sql/presto/prestoAutocompleteParser.js`],
  84. 'prestoSyntaxParser': [`${JS_ROOT}/parse/sql/presto/prestoSyntaxParser.js`]
  85. },
  86. performance: {
  87. hints: false,
  88. maxEntrypointSize: 1500000,
  89. maxAssetSize: 1500000
  90. },
  91. output: {
  92. path: `${DIST_DIR}/parsers`,
  93. library: '[name]',
  94. libraryExport: "default",
  95. libraryTarget: 'umd'
  96. },
  97. });
  98. module.exports = [
  99. npmSetupConfig,
  100. webComponentsConfig,
  101. parserConf
  102. ];