webpack.config.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. },
  39. stats: {
  40. colors: true
  41. },
  42. plugins: [
  43. new CleanWebpackPlugin({
  44. cleanOnceBeforeBuildPatterns:[path.resolve(__dirname, 'build/**/*')],
  45. watch: true
  46. }),
  47. new UpdateVersionPlugin(),
  48. new HtmlWebpackPlugin({
  49. template: 'templates/index.html',
  50. filename: path.resolve(__dirname, 'build', 'index.html')
  51. }),
  52. new HtmlWebpackPlugin({
  53. template: 'templates/runner.html',
  54. filename: path.resolve(__dirname, 'build', 'runner.html')
  55. }),
  56. /*new ChangeScriptSourcePlugin(),*/
  57. new CopyPlugin([
  58. {from:'js/iassign-integration-functions.js', to:path.resolve(__dirname, 'build/js')},
  59. {from:"css/ivprog-visual-1.0.css", to:path.resolve(__dirname, 'build/css')},
  60. {from:"css/ivprog-term.css", to:path.resolve(__dirname, 'build/css')},
  61. {from:"css/ivprog-assessment.css", to:path.resolve(__dirname, 'build/css')},
  62. {from:"css/ivprog-editor.css", to:path.resolve(__dirname, 'build/css')},
  63. {from:"css/roboto.css", to:path.resolve(__dirname, 'build/css')},
  64. {from:"css/fonts/", to:path.resolve(__dirname, 'build/css/fonts')},
  65. {from:'js/Sortable.js', to:path.resolve(__dirname, 'build/js')},
  66. {from: 'img/trash-icon.png', to:path.resolve(__dirname, 'build/img')},
  67. {from: 'img/empty.svg', to:path.resolve(__dirname, 'build/img')},
  68. {from:'js/jquery.json-editor.min.js', to:path.resolve(__dirname, 'build/js')},
  69. {from:'node_modules/codemirror/lib/codemirror.css', to:path.resolve(__dirname, 'build/css')},
  70. {from:'node_modules/codemirror/addon/hint/show-hint.css', to:path.resolve(__dirname, 'build/css')},
  71. {from:'node_modules/codemirror/theme/ttcn.css', to:path.resolve(__dirname, 'build/css')},
  72. /*{from:'index.html', to:path.resolve(__dirname, 'build')},
  73. {from:'runner.html', to:path.resolve(__dirname, 'build')},*/
  74. ])
  75. ],
  76. optimization: {
  77. splitChunks: {
  78. chunks: 'all'
  79. }
  80. },
  81. devtool: 'source-map',
  82. watchOptions: {
  83. ignored: [
  84. path.resolve(__dirname, '.ima_version.json'),
  85. ]
  86. }
  87. };