webpack.config.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/,
  67. loader: "babel-loader?compact=false"
  68. },
  69. {
  70. test: /\.css$/,
  71. use: ExtractTextPlugin.extract({
  72. use: [
  73. { loader: "css-loader?minimize" },
  74. { loader: "postcss-loader" },
  75. ]
  76. })
  77. },
  78. {
  79. test: /\.less$/,
  80. use: ExtractTextPlugin.extract({
  81. use: [
  82. { loader: "css-loader?minimize" },
  83. { loader: "postcss-loader" },
  84. { loader: "less-loader" }
  85. ]
  86. })
  87. },
  88. {
  89. test: /\.(ico|eot|ttf|woff|woff2)$/,
  90. loader: "url-loader",
  91. options: {
  92. limit: 10000
  93. }
  94. },
  95. { // First party images are saved as files to be cached
  96. test: /\.(png|jpg|gif|svg)$/,
  97. exclude: /node_modules/,
  98. loader: "file-loader",
  99. options: {
  100. name: "images/[name].[ext]"
  101. }
  102. },
  103. { // Third party images are inlined
  104. test: /\.(png|jpg|gif|svg)$/,
  105. exclude: /web\/static/,
  106. loader: "url-loader",
  107. options: {
  108. limit: 10000
  109. }
  110. },
  111. ]
  112. },
  113. stats: {
  114. children: false,
  115. chunks: false,
  116. modules: false,
  117. entrypoints: false,
  118. warningsFilter: /source-map/,
  119. },
  120. node: {
  121. fs: "empty"
  122. },
  123. performance: {
  124. hints: false
  125. }
  126. };