webpack.config.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. var path = require('path');
  2. var HtmlWebpackPlugin = require('html-webpack-plugin');
  3. var UpdateVersionPlugin = require('./updateVersionPlugin');
  4. //var ChangeScriptSourcePlugin = require('./changeScriptSourcePlugin');
  5. var CopyPlugin = require('copy-webpack-plugin');
  6. var CleanWebpackPlugin = require('clean-webpack-plugin');
  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. },
  44. resolve: {
  45. extensions: [ '.tsx', '.ts', '.js' ]
  46. },
  47. stats: {
  48. colors: true
  49. },
  50. plugins: [
  51. new CleanWebpackPlugin({
  52. cleanOnceBeforeBuildPatterns:[path.resolve(__dirname, 'build/**/*')],
  53. watch: true
  54. }),
  55. new UpdateVersionPlugin(),
  56. new HtmlWebpackPlugin({
  57. template: 'templates/index.html',
  58. filename: path.resolve(__dirname, 'build', 'index.html')
  59. }),
  60. new HtmlWebpackPlugin({
  61. template: 'templates/runner.html',
  62. filename: path.resolve(__dirname, 'build', 'runner.html')
  63. }),
  64. /*new ChangeScriptSourcePlugin(),*/
  65. new CopyPlugin([
  66. {from:'js/iassign-integration-functions.js', to:path.resolve(__dirname, 'build/js')},
  67. {from:"css/ivprog-visual-1.0.css", to:path.resolve(__dirname, 'build/css')},
  68. {from:"css/ivprog-term.css", to:path.resolve(__dirname, 'build/css')},
  69. {from:"css/ivprog-assessment.css", to:path.resolve(__dirname, 'build/css')},
  70. {from:"css/ivprog-editor.css", to:path.resolve(__dirname, 'build/css')},
  71. {from:"css/roboto.css", to:path.resolve(__dirname, 'build/css')},
  72. {from:"css/fonts/", to:path.resolve(__dirname, 'build/css/fonts')},
  73. {from:'js/Sortable.js', to:path.resolve(__dirname, 'build/js')},
  74. {from: 'img/trash-icon.png', to:path.resolve(__dirname, 'build/img')},
  75. {from: 'img/empty.svg', to:path.resolve(__dirname, 'build/img')},
  76. {from:'js/jquery.json-editor.min.js', to:path.resolve(__dirname, 'build/js')},
  77. {from:'node_modules/codemirror/lib/codemirror.css', to:path.resolve(__dirname, 'build/css')},
  78. {from:'node_modules/codemirror/addon/hint/show-hint.css', to:path.resolve(__dirname, 'build/css')},
  79. {from:'node_modules/codemirror/theme/ttcn.css', to:path.resolve(__dirname, 'build/css')},
  80. /*{from:'index.html', to:path.resolve(__dirname, 'build')},
  81. {from:'runner.html', to:path.resolve(__dirname, 'build')},*/
  82. ])
  83. ],
  84. optimization: {
  85. splitChunks: {
  86. chunks: 'all'
  87. }
  88. },
  89. devtool: 'source-map',
  90. watchOptions: {
  91. ignored: [
  92. path.resolve(__dirname, '.ima_version.json'),
  93. ]
  94. }
  95. };