webpack.config.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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');
  7. const CSVLoader = require("./i18n_csv_loader");
  8. module.exports = {
  9. entry: path.resolve(__dirname, 'js/main.js'),
  10. output: {
  11. path: path.resolve(__dirname, 'build',"js"),
  12. filename: '[name].[contenthash].js',
  13. library: 'ivprogCore',
  14. libraryTarget: 'umd'
  15. },
  16. node: {
  17. fs: 'empty',
  18. },
  19. module: {
  20. rules: [
  21. {
  22. test: /\.js$/,
  23. exclude: /(node_modules)/,
  24. use: {
  25. loader: "babel-loader",
  26. options: {
  27. presets: ["@babel/preset-env"]
  28. }
  29. }
  30. },
  31. {
  32. test: /\.g4$/,
  33. exclude: /(node_modules)/,
  34. use: {
  35. loader:'antlr4-webpack-loader'
  36. }
  37. },
  38. {
  39. test: /\.tsx?$/,
  40. use: 'ts-loader',
  41. exclude: /node_modules/
  42. },
  43. {
  44. test: /\.csv$/,
  45. use: [
  46. {
  47. loader: path.resolve(__dirname, 'i18n_csv_loader')
  48. }
  49. ],
  50. exclude: /node_modules/
  51. }
  52. ]
  53. },
  54. resolve: {
  55. extensions: [ '.tsx', '.ts', '.js' ]
  56. },
  57. stats: {
  58. colors: true
  59. },
  60. plugins: [
  61. new CleanWebpackPlugin({
  62. cleanOnceBeforeBuildPatterns:[path.resolve(__dirname, 'build/**/*')],
  63. watch: true
  64. }),
  65. new UpdateVersionPlugin(),
  66. new HtmlWebpackPlugin({
  67. template: 'templates/index.html',
  68. filename: path.resolve(__dirname, 'build', 'index.html')
  69. }),
  70. new HtmlWebpackPlugin({
  71. template: 'templates/runner.html',
  72. filename: path.resolve(__dirname, 'build', 'runner.html')
  73. }),
  74. /*new ChangeScriptSourcePlugin(),*/
  75. new CopyPlugin([
  76. {from:'js/iassign-integration-functions.js', to:path.resolve(__dirname, 'build/js')},
  77. {from:"css/ivprog-visual-1.0.css", to:path.resolve(__dirname, 'build/css')},
  78. {from:"css/ivprog-term.css", to:path.resolve(__dirname, 'build/css')},
  79. {from:"css/ivprog-assessment.css", to:path.resolve(__dirname, 'build/css')},
  80. {from:"css/ivprog-editor.css", to:path.resolve(__dirname, 'build/css')},
  81. {from:"css/roboto.css", to:path.resolve(__dirname, 'build/css')},
  82. {from:"css/fonts/", to:path.resolve(__dirname, 'build/css/fonts')},
  83. {from:'js/Sortable.js', to:path.resolve(__dirname, 'build/js')},
  84. {from: 'img/trash-icon.png', to:path.resolve(__dirname, 'build/img')},
  85. {from: 'img/empty.svg', to:path.resolve(__dirname, 'build/img')},
  86. {from:'js/jquery.json-editor.min.js', to:path.resolve(__dirname, 'build/js')},
  87. {from:'node_modules/codemirror/lib/codemirror.css', to:path.resolve(__dirname, 'build/css')},
  88. {from:'node_modules/codemirror/addon/hint/show-hint.css', to:path.resolve(__dirname, 'build/css')},
  89. {from:'node_modules/codemirror/theme/ttcn.css', to:path.resolve(__dirname, 'build/css')},
  90. /*{from:'index.html', to:path.resolve(__dirname, 'build')},
  91. {from:'runner.html', to:path.resolve(__dirname, 'build')},*/
  92. ])
  93. ],
  94. optimization: {
  95. splitChunks: {
  96. chunks: 'all'
  97. }
  98. },
  99. devtool: 'source-map',
  100. watchOptions: {
  101. ignored: [
  102. path.resolve(__dirname, '.ima_version.json'),
  103. ]
  104. }
  105. };