webpack.config.js 3.4 KB

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