webpack.config.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. "node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
  48. "node --experimental-modules src/core/config/scripts/generateConfig.mjs",
  49. "echo ---\nConfig scripts finished.\n---\n"
  50. ],
  51. blocking: true,
  52. parallel: false
  53. }
  54. })
  55. ],
  56. resolve: {
  57. alias: {
  58. jquery: "jquery/src/jquery"
  59. }
  60. },
  61. module: {
  62. rules: [
  63. {
  64. test: /\.m?js$/,
  65. exclude: /node_modules/,
  66. loader: "babel-loader?compact=false"
  67. },
  68. {
  69. test: /\.css$/,
  70. use: ExtractTextPlugin.extract({
  71. use: [
  72. { loader: "css-loader?minimize" },
  73. { loader: "postcss-loader" },
  74. ]
  75. })
  76. },
  77. {
  78. test: /\.less$/,
  79. use: ExtractTextPlugin.extract({
  80. use: [
  81. { loader: "css-loader?minimize" },
  82. { loader: "postcss-loader" },
  83. { loader: "less-loader" }
  84. ]
  85. })
  86. },
  87. {
  88. test: /\.(ico|eot|ttf|woff|woff2)$/,
  89. loader: "url-loader",
  90. options: {
  91. limit: 10000
  92. }
  93. },
  94. { // First party images are saved as files to be cached
  95. test: /\.(png|jpg|gif|svg)$/,
  96. exclude: /node_modules/,
  97. loader: "file-loader",
  98. options: {
  99. name: "images/[name].[ext]"
  100. }
  101. },
  102. { // Third party images are inlined
  103. test: /\.(png|jpg|gif|svg)$/,
  104. exclude: /web\/static/,
  105. loader: "url-loader",
  106. options: {
  107. limit: 10000
  108. }
  109. },
  110. ]
  111. },
  112. stats: {
  113. children: false,
  114. chunks: false,
  115. modules: false,
  116. entrypoints: false,
  117. warningsFilter: /source-map/,
  118. },
  119. node: {
  120. fs: "empty"
  121. },
  122. performance: {
  123. hints: false
  124. }
  125. };