webpack.config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. const webpack = require("webpack");
  2. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  3. const path = require("path");
  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 2016
  15. * @license Apache-2.0
  16. *
  17. * Copyright 2016 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 webpack.DefinePlugin({
  44. "process.browser": "true"
  45. }),
  46. new MiniCssExtractPlugin({
  47. filename: "assets/[name].css"
  48. }),
  49. ],
  50. resolve: {
  51. alias: {
  52. jquery: "jquery/src/jquery"
  53. }
  54. },
  55. module: {
  56. rules: [
  57. {
  58. test: /\.m?js$/,
  59. exclude: /node_modules\/(?!jsesc|crypto-api)/,
  60. options: {
  61. configFile: path.resolve(__dirname, "babel.config.js"),
  62. cacheDirectory: true,
  63. compact: false
  64. },
  65. type: "javascript/auto",
  66. loader: "babel-loader"
  67. },
  68. {
  69. test: /forge.min.js$/,
  70. loader: "imports-loader?jQuery=>null"
  71. },
  72. {
  73. test: /bootstrap-material-design/,
  74. loader: "imports-loader?Popper=popper.js/dist/umd/popper.js"
  75. },
  76. {
  77. test: /\.css$/,
  78. use: [
  79. {
  80. loader: MiniCssExtractPlugin.loader,
  81. options: {
  82. publicPath: "../"
  83. }
  84. },
  85. "css-loader",
  86. "postcss-loader",
  87. ]
  88. },
  89. {
  90. test: /\.scss$/,
  91. use: [
  92. {
  93. loader: MiniCssExtractPlugin.loader,
  94. options: {
  95. publicPath: "../"
  96. }
  97. },
  98. "css-loader",
  99. "sass-loader",
  100. ]
  101. },
  102. {
  103. test: /\.(ico|eot|ttf|woff|woff2)$/,
  104. loader: "url-loader",
  105. options: {
  106. limit: 10000,
  107. name: "[hash].[ext]",
  108. outputPath: "assets"
  109. }
  110. },
  111. {
  112. test: /\.svg$/,
  113. loader: "svg-url-loader",
  114. options: {
  115. encoding: "base64"
  116. }
  117. },
  118. { // First party images are saved as files to be cached
  119. test: /\.(png|jpg|gif)$/,
  120. exclude: /node_modules/,
  121. loader: "file-loader",
  122. options: {
  123. name: "images/[name].[ext]"
  124. }
  125. },
  126. { // Third party images are inlined
  127. test: /\.(png|jpg|gif)$/,
  128. exclude: /web\/static/,
  129. loader: "url-loader",
  130. options: {
  131. limit: 10000,
  132. name: "[hash].[ext]",
  133. outputPath: "assets"
  134. }
  135. },
  136. ]
  137. },
  138. stats: {
  139. children: false,
  140. chunks: false,
  141. modules: false,
  142. entrypoints: false,
  143. warningsFilter: [
  144. /source-map/,
  145. /dependency is an expression/,
  146. /export 'default'/,
  147. /Can't resolve 'sodium'/
  148. ],
  149. },
  150. node: {
  151. fs: "empty",
  152. "child_process": "empty",
  153. net: "empty",
  154. tls: "empty"
  155. },
  156. performance: {
  157. hints: false
  158. }
  159. };