webpack.conf.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var webpack = require('webpack');
  2. var path = require('path');
  3. var TerserPlugin = require('terser-webpack-plugin');
  4. var isProd = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'production-wip';
  5. var VueLoaderPlugin = require('vue-loader/lib/plugin');
  6. const ESLintWebpackPlugin = require('eslint-webpack-plugin');
  7. module.exports = {
  8. entry: {
  9. 'flex-objects': './app/main.js'
  10. },
  11. devtool: isProd ? false : 'eval-source-map',
  12. target: 'web',
  13. output: {
  14. path: path.resolve(__dirname, 'js'),
  15. filename: '[name].js',
  16. chunkFilename: 'flex-objects-vendor.js'
  17. },
  18. optimization: {
  19. minimize: isProd,
  20. minimizer: [
  21. new TerserPlugin({
  22. terserOptions: {
  23. compress: {
  24. drop_console: true
  25. },
  26. dead_code: true
  27. }
  28. })
  29. ]
  30. /* , splitChunks: {
  31. cacheGroups: {
  32. vendors: {
  33. test: /[\\/]node_modules[\\/]/,
  34. priority: 1,
  35. name: 'vendor',
  36. enforce: true,
  37. chunks: 'all'
  38. }
  39. }
  40. }*/
  41. },
  42. plugins: [
  43. new webpack.ProvidePlugin({
  44. 'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
  45. }),
  46. new VueLoaderPlugin(),
  47. new ESLintWebpackPlugin()
  48. ],
  49. externals: {
  50. jquery: 'jQuery',
  51. 'grav-config': 'GravConfig'
  52. },
  53. module: {
  54. rules: [
  55. {
  56. test: /\.css$/,
  57. use: [
  58. 'vue-style-loader',
  59. 'css-loader'
  60. ]
  61. },
  62. {
  63. test: /\.js$/,
  64. loader: 'babel-loader',
  65. options: {
  66. presets: ['@babel/preset-env'],
  67. plugins: ['@babel/plugin-proposal-object-rest-spread']
  68. }
  69. },
  70. { test: /\.vue$/, use: ['vue-loader'] },
  71. { test: /\.(png|jpg|gif|svg)$/, loader: 'file', options: { name: '[name].[ext]?[hash]' } }
  72. ]
  73. }
  74. };