webpack.config.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. const path = require("path");
  2. const HtmlWebpackPlugin = require("html-webpack-plugin");
  3. const UpdateVersionPlugin = require("./updateVersionPlugin");
  4. //const ChangeScriptSourcePlugin = require('./changeScriptSourcePlugin');
  5. const CopyPlugin = require("copy-webpack-plugin");
  6. const CleanWebpackPlugin = require("clean-webpack-plugin").CleanWebpackPlugin;
  7. module.exports = {
  8. entry: path.resolve(__dirname, "js/main.js"),
  9. output: {
  10. path: path.resolve(__dirname, "build", "js"),
  11. filename: "[name].[contenthash].js",
  12. library: "ivprogCore",
  13. libraryTarget: "umd",
  14. },
  15. node: {
  16. fs: "empty",
  17. },
  18. module: {
  19. rules: [
  20. {
  21. test: /\.js$/,
  22. exclude: /(node_modules)/,
  23. use: {
  24. loader: "babel-loader",
  25. options: {
  26. presets: ["@babel/preset-env"],
  27. },
  28. },
  29. },
  30. {
  31. test: /\.g4$/,
  32. exclude: /(node_modules)/,
  33. use: {
  34. loader: "antlr4-webpack-loader",
  35. },
  36. },
  37. {
  38. test: /\.tsx?$/,
  39. use: "ts-loader",
  40. exclude: /node_modules/,
  41. },
  42. {
  43. test: /\.csv$/,
  44. use: [
  45. {
  46. loader: path.resolve(__dirname, "i18n_csv_loader"),
  47. },
  48. ],
  49. exclude: /node_modules/,
  50. },
  51. ],
  52. },
  53. resolve: {
  54. extensions: [".tsx", ".ts", ".js", ".csv"],
  55. },
  56. stats: {
  57. colors: true,
  58. },
  59. plugins: [
  60. new CleanWebpackPlugin({
  61. cleanOnceBeforeBuildPatterns: [path.resolve(__dirname, "build/**/*")],
  62. watch: true,
  63. }),
  64. new UpdateVersionPlugin(),
  65. new HtmlWebpackPlugin({
  66. template: "templates/index.html",
  67. filename: path.resolve(__dirname, "build", "index.html"),
  68. }),
  69. new HtmlWebpackPlugin({
  70. template: "templates/runner.html",
  71. filename: path.resolve(__dirname, "build", "runner.html"),
  72. }),
  73. /*new ChangeScriptSourcePlugin(),*/
  74. new CopyPlugin([
  75. {
  76. from: "js/iassign-integration-functions.js",
  77. to: path.resolve(__dirname, "build/js"),
  78. },
  79. {
  80. from: "css/ivprog-visual-1.0.css",
  81. to: path.resolve(__dirname, "build/css"),
  82. },
  83. {from: "css/ivprog-term.css", to: path.resolve(__dirname, "build/css")},
  84. {
  85. from: "css/ivprog-assessment.css",
  86. to: path.resolve(__dirname, "build/css"),
  87. },
  88. {
  89. from: "css/ivprog-editor.css",
  90. to: path.resolve(__dirname, "build/css"),
  91. },
  92. {from: "css/roboto.css", to: path.resolve(__dirname, "build/css")},
  93. {from: "css/fonts/", to: path.resolve(__dirname, "build/css/fonts")},
  94. {from: "js/Sortable.js", to: path.resolve(__dirname, "build/js")},
  95. {from: "js/jquery.min.js", to: path.resolve(__dirname, "build/js")},
  96. {from: "js/jquery-ui.min.js", to: path.resolve(__dirname, "build/js")},
  97. {from: "js/semantic.min.js", to: path.resolve(__dirname, "build/js")},
  98. {
  99. from: "css/semantic.min.css",
  100. to: path.resolve(__dirname, "build/css"),
  101. },
  102. {from: "css/themes/", to: path.resolve(__dirname, "build/css/themes")},
  103. {from: "img/trash-icon.png", to: path.resolve(__dirname, "build/img")},
  104. {from: "img/empty.svg", to: path.resolve(__dirname, "build/img")},
  105. {from: "img/new_line.svg", to: path.resolve(__dirname, "build/img")},
  106. {from: "img/no_new_line.svg", to: path.resolve(__dirname, "build/img")},
  107. {
  108. from: "js/jquery.json-editor.min.js",
  109. to: path.resolve(__dirname, "build/js"),
  110. },
  111. {
  112. from: "node_modules/codemirror/lib/codemirror.css",
  113. to: path.resolve(__dirname, "build/css"),
  114. },
  115. {
  116. from: "node_modules/codemirror/addon/hint/show-hint.css",
  117. to: path.resolve(__dirname, "build/css"),
  118. },
  119. {
  120. from: "node_modules/codemirror/theme/ttcn.css",
  121. to: path.resolve(__dirname, "build/css"),
  122. },
  123. /*{from:'index.html', to:path.resolve(__dirname, 'build')},
  124. {from:'runner.html', to:path.resolve(__dirname, 'build')},*/
  125. // Accessible UI
  126. {from: "css/accessible/bootstrap/bootstrap.css", to: path.resolve(__dirname, "build/css/accessible/bootstrap")},
  127. {from: "css/accessible/bootstrap/bootstrap-grid.css", to: path.resolve(__dirname, "build/css/accessible/bootstrap")},
  128. {from: "css/accessible/bootstrap/bootstrap-reboot.css", to: path.resolve(__dirname, "build/css/accessible/bootstrap")},
  129. {from: "css/accessible/design.css", to: path.resolve(__dirname, "build/css/accessible")},
  130. {from: "css/accessible/forms_var_comand.css", to: path.resolve(__dirname, "build/css/accessible")},
  131. {from: "css/accessible/style.css", to: path.resolve(__dirname, "build/css/accessible")},
  132. {from: "js/accessibleUI/bootstrap/bootstrap.bundle.js", to: path.resolve(__dirname, "build/js/accessible/bootstrap"),},
  133. {from: "js/accessibleUI/bootstrap/bootstrap.js", to: path.resolve(__dirname, "build/js/accessible/bootstrap"),},
  134. ]),
  135. ],
  136. optimization: {
  137. splitChunks: {
  138. chunks: "all",
  139. },
  140. },
  141. devtool: "source-map",
  142. watchOptions: {
  143. ignored: [path.resolve(__dirname, ".ima_version.json")],
  144. }
  145. };