webpack.config.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. module: {
  16. rules: [
  17. {
  18. test: /\.js$/,
  19. exclude: /(node_modules)/,
  20. use: {
  21. loader: "babel-loader",
  22. options: {
  23. presets: ["@babel/preset-env"],
  24. },
  25. },
  26. },
  27. {
  28. test: /\.tsx?$/,
  29. use: "ts-loader",
  30. exclude: /node_modules/,
  31. },
  32. {
  33. test: /\.csv$/,
  34. use: [
  35. {
  36. loader: path.resolve(__dirname, "i18n_csv_loader"),
  37. },
  38. ],
  39. exclude: /node_modules/,
  40. },
  41. ],
  42. },
  43. resolve: {
  44. extensions: [".tsx", ".ts", ".js", ".csv"],
  45. fallback: {
  46. fs: false,
  47. },
  48. },
  49. stats: {
  50. colors: true,
  51. },
  52. plugins: [
  53. new CleanWebpackPlugin({
  54. cleanOnceBeforeBuildPatterns: [path.resolve(__dirname, "build/**/*")],
  55. watch: true,
  56. }),
  57. new UpdateVersionPlugin(),
  58. new HtmlWebpackPlugin({
  59. template: "./templates/index.html",
  60. filename: path.resolve(__dirname, "build", "index.html"),
  61. }),
  62. new HtmlWebpackPlugin({
  63. template: "./templates/runner.html",
  64. filename: path.resolve(__dirname, "build", "runner.html"),
  65. }),
  66. new HtmlWebpackPlugin({
  67. template: "./templates/process.html",
  68. filename: path.resolve(__dirname, "build", "process.html"),
  69. }),
  70. /*new ChangeScriptSourcePlugin(),*/
  71. new CopyPlugin({
  72. patterns: [
  73. {
  74. from: "js/iassign-integration-functions.js",
  75. to: path.resolve(__dirname, "build/js"),
  76. },
  77. {
  78. from: "css/ivprog-visual-1.0.css",
  79. to: path.resolve(__dirname, "build/css"),
  80. },
  81. {
  82. from: "css/ivprog-term.css",
  83. to: path.resolve(__dirname, "build/css"),
  84. },
  85. {
  86. from: "css/ivprog-assessment.css",
  87. to: path.resolve(__dirname, "build/css"),
  88. },
  89. {
  90. from: "css/ivprog-editor.css",
  91. to: path.resolve(__dirname, "build/css"),
  92. },
  93. { from: "css/roboto.css", to: path.resolve(__dirname, "build/css") },
  94. { from: "css/fonts/", to: path.resolve(__dirname, "build/css/fonts") },
  95. { from: "js/Sortable.js", to: path.resolve(__dirname, "build/js") },
  96. { from: "js/jquery.min.js", to: path.resolve(__dirname, "build/js") },
  97. {
  98. from: "js/jquery-ui.min.js",
  99. to: path.resolve(__dirname, "build/js"),
  100. },
  101. { from: "js/semantic.min.js", to: path.resolve(__dirname, "build/js") },
  102. {
  103. from: "js/filesaver.min.js",
  104. to: path.resolve(__dirname, "build/js"),
  105. },
  106. {
  107. from: "css/semantic.min.css",
  108. to: path.resolve(__dirname, "build/css"),
  109. },
  110. {
  111. from: "css/themes/",
  112. to: path.resolve(__dirname, "build/css/themes"),
  113. },
  114. {
  115. from: "img/trash-icon.png",
  116. to: path.resolve(__dirname, "build/img"),
  117. },
  118. { from: "img/empty.svg", to: path.resolve(__dirname, "build/img") },
  119. { from: "img/new_line.svg", to: path.resolve(__dirname, "build/img") },
  120. {
  121. from: "img/no_new_line.svg",
  122. to: path.resolve(__dirname, "build/img"),
  123. },
  124. {
  125. from: "js/jquery.json-editor.min.js",
  126. to: path.resolve(__dirname, "build/js"),
  127. },
  128. {
  129. from: "node_modules/codemirror/lib/codemirror.css",
  130. to: path.resolve(__dirname, "build/css"),
  131. },
  132. {
  133. from: "node_modules/codemirror/addon/hint/show-hint.css",
  134. to: path.resolve(__dirname, "build/css"),
  135. },
  136. {
  137. from: "node_modules/codemirror/theme/ttcn.css",
  138. to: path.resolve(__dirname, "build/css"),
  139. },
  140. /*{from:'index.html', to:path.resolve(__dirname, 'build')},
  141. {from:'runner.html', to:path.resolve(__dirname, 'build')},*/
  142. ],
  143. }),
  144. ],
  145. optimization: {
  146. splitChunks: {
  147. chunks: "all",
  148. },
  149. },
  150. devtool: "source-map",
  151. watchOptions: {
  152. ignored: [path.resolve(__dirname, ".ima_version.json")],
  153. },
  154. };