webpack.config.js 3.3 KB

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