webpack.config.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. const webpack = require("webpack");
  2. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  3. const WebpackSyncShellPlugin = require("webpack-synchronizable-shell-plugin");
  4. /**
  5. * Webpack configuration details for use with Grunt.
  6. *
  7. * @author n1474335 [n1474335@gmail.com]
  8. * @copyright Crown Copyright 2017
  9. * @license Apache-2.0
  10. */
  11. const banner = `/**
  12. * CyberChef - The Cyber Swiss Army Knife
  13. *
  14. * @copyright Crown Copyright 2017
  15. * @license Apache-2.0
  16. *
  17. * Copyright 2017 Crown Copyright
  18. *
  19. * Licensed under the Apache License, Version 2.0 (the "License");
  20. * you may not use this file except in compliance with the License.
  21. * You may obtain a copy of the License at
  22. *
  23. * http://www.apache.org/licenses/LICENSE-2.0
  24. *
  25. * Unless required by applicable law or agreed to in writing, software
  26. * distributed under the License is distributed on an "AS IS" BASIS,
  27. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. * See the License for the specific language governing permissions and
  29. * limitations under the License.
  30. */`;
  31. module.exports = {
  32. plugins: [
  33. new webpack.ProvidePlugin({
  34. $: "jquery",
  35. jQuery: "jquery",
  36. log: "loglevel"
  37. }),
  38. new webpack.BannerPlugin({
  39. banner: banner,
  40. raw: true,
  41. entryOnly: true
  42. }),
  43. new ExtractTextPlugin("styles.css"),
  44. new WebpackSyncShellPlugin({
  45. onBuildStart: {
  46. scripts: [
  47. "echo \n--- Generating config files. ---",
  48. "node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
  49. "node --experimental-modules src/core/config/scripts/generateConfig.mjs",
  50. "echo --- Config scripts finished. ---\n"
  51. ],
  52. blocking: true,
  53. parallel: false
  54. }
  55. })
  56. ],
  57. resolve: {
  58. alias: {
  59. jquery: "jquery/src/jquery"
  60. }
  61. },
  62. module: {
  63. rules: [
  64. {
  65. test: /\.m?js$/,
  66. exclude: /node_modules\/(?!jsesc)/,
  67. type: "javascript/auto",
  68. loader: "babel-loader?compact=false"
  69. },
  70. {
  71. test: /forge.min.js$/,
  72. loader: "imports-loader?jQuery=>null"
  73. },
  74. {
  75. test: /\.css$/,
  76. use: ExtractTextPlugin.extract({
  77. use: [
  78. { loader: "css-loader?minimize" },
  79. { loader: "postcss-loader" },
  80. ]
  81. })
  82. },
  83. {
  84. test: /\.less$/,
  85. use: ExtractTextPlugin.extract({
  86. use: [
  87. { loader: "css-loader?minimize" },
  88. { loader: "postcss-loader" },
  89. { loader: "less-loader" }
  90. ]
  91. })
  92. },
  93. {
  94. test: /\.(ico|eot|ttf|woff|woff2)$/,
  95. loader: "url-loader",
  96. options: {
  97. limit: 10000
  98. }
  99. },
  100. { // First party images are saved as files to be cached
  101. test: /\.(png|jpg|gif|svg)$/,
  102. exclude: /node_modules/,
  103. loader: "file-loader",
  104. options: {
  105. name: "images/[name].[ext]"
  106. }
  107. },
  108. { // Third party images are inlined
  109. test: /\.(png|jpg|gif|svg)$/,
  110. exclude: /web\/static/,
  111. loader: "url-loader",
  112. options: {
  113. limit: 10000
  114. }
  115. },
  116. ]
  117. },
  118. stats: {
  119. children: false,
  120. chunks: false,
  121. modules: false,
  122. entrypoints: false,
  123. warningsFilter: [/source-map/, /dependency is an expression/],
  124. },
  125. node: {
  126. fs: "empty"
  127. },
  128. performance: {
  129. hints: false
  130. }
  131. };