Browse Source

webpack: remove eslint, added terser optimization in prod build

Bachir Soussi Chiadmi 3 years ago
parent
commit
f002c81008
7 changed files with 1545 additions and 319 deletions
  1. 0 8
      .eslintignore
  2. 0 29
      .eslintrc.js
  3. 12 11
      build/webpack.config.base.js
  4. 0 1
      build/webpack.config.dev.js
  5. 19 31
      build/webpack.config.prod.js
  6. 1493 216
      package-lock.json
  7. 21 23
      package.json

+ 0 - 8
.eslintignore

@@ -1,8 +0,0 @@
-core/**/*
-vendor/**/*
-sites/**/files/**/*
-libraries/**/*
-sites/**/libraries/**/*
-profiles/**/libraries/**/*
-**/js_test_files/**/*
-**/node_modules/**/*

+ 0 - 29
.eslintrc.js

@@ -1,29 +0,0 @@
-module.exports =
-  root: true,
-  parserOptions: {
-    parser: 'babel-eslint'
-  },
-  env: {
-    browser: true,
-    node: true,
-    mocha: true
-  },
-  globals: {
-    "expect": true,
-    "jQuery": false
-  },
-  extends: [
-    './web/core/.eslintrc.json',
-    'plugin:vue/recommended',
-    'plugin:vue-a11y/base',
-    'standard'
-  ],
-  plugins: [
-    'vue',
-    'vue-a11y'
-  ],
-  rules: {
-    'generator-star-spacing': 'off',
-    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
-  }
-}

+ 12 - 11
build/webpack.config.base.js

@@ -1,7 +1,7 @@
 'use strict'
-
 const MiniCssExtractPlugin = require("mini-css-extract-plugin");
 const { VueLoaderPlugin } = require('vue-loader')
+const ESLintPlugin = require('eslint-webpack-plugin');
 
 const utils = require('./utils')
 
@@ -25,16 +25,16 @@ module.exports = {
   },
   module: {
     rules: [
-      {
-        test: /\.(js|vue)$/,
-        loader: 'eslint-loader',
-        enforce: 'pre',
-        exclude: /node_modules/,
-        options: {
-          emitError: true,
-          emitWarning: true
-        }
-      },
+      // {
+      //   test: /\.(js|vue)$/,
+      //   loader: 'eslint-loader',
+      //   enforce: 'pre',
+      //   exclude: /node_modules/,
+      //   options: {
+      //     emitError: true,
+      //     emitWarning: true
+      //   }
+      // },
       {
         test: /\.vue$/,
         use: 'vue-loader'
@@ -82,5 +82,6 @@ module.exports = {
       filename: '[name].css'
     }),
     new VueLoaderPlugin()
+    // new ESLintPlugin()
   ]
 }

+ 0 - 1
build/webpack.config.dev.js

@@ -7,7 +7,6 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
 
 module.exports = merge(baseConfig, {
   mode: 'development',
-
   module: {
     rules: [
       {

+ 19 - 31
build/webpack.config.prod.js

@@ -4,35 +4,10 @@ const webpack = require('webpack')
 const merge = require('webpack-merge')
 const baseConfig = require('./webpack.config.base')
 const MiniCssExtractPlugin  = require('mini-css-extract-plugin')
-const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
+const TerserPlugin = require("terser-webpack-plugin");
 
 module.exports = merge(baseConfig, {
   mode: 'production',
-  optimization: {
-    minimizer: [
-      new UglifyJSPlugin({
-        uglifyOptions: {
-          // Eliminate comments
-          comments: false,
-          // remove warnings
-          warnings: false,
-          compress: {
-            // Drop console statements
-            drop_console: true,
-          }
-        }
-      })
-    ]
-  //   splitChunks: {
-  //     cacheGroups: {
-  //       commons: {
-  //         test: /[\\/]node_modules[\\/]/,
-  //         name: "vendor",
-  //         chunks: "all",
-  //       },
-  //     },
-  //   },
-  },
   module: {
     rules: [
       {
@@ -61,9 +36,22 @@ module.exports = merge(baseConfig, {
       }
     ]
   },
-  plugins: [
-    // new MiniCssExtractPlugin({
-    //   filename: 'main.css'
-    // })
-  ]
+  optimization: {
+    minimize: true,
+    minimizer: [
+      new TerserPlugin({
+        sourceMap: true, // Must be set to true if using source-maps in production
+        parallel: true,
+        test: /\.(js|vue)$/,
+        // extractComments: true
+        terserOptions: {
+          compress: {
+            drop_console: true,
+          },
+        },
+      })
+    ],
+  },
+  // ,
+  // plugins: []
 })

File diff suppressed because it is too large
+ 1493 - 216
package-lock.json


+ 21 - 23
package.json

@@ -19,53 +19,51 @@
   "license": "MIT",
   "dependencies": {
     "axios": "^0.18.1",
-    "vue": "^2.6.10",
+    "vue": "^2.6.12",
     "vue-autofocus-directive": "^1.0.4",
-    "vue-cool-lightbox": "^1.0.11",
-    "vue-infinite-loading": "^2.4.4",
+    "vue-cool-lightbox": "^1.1.0",
+    "vue-infinite-loading": "^2.4.5",
     "vue-meta": "^1.6.0",
-    "vue-router": "^3.1.3",
+    "vue-router": "^3.4.9",
     "vue-vimeo-player": "^0.1.0",
     "vue-youtube-embed": "^2.2.2",
-    "vuex": "^3.1.1"
+    "vuex": "^3.5.1"
   },
   "devDependencies": {
-    "@babel/core": "^7.7.0",
-    "@babel/preset-env": "^7.7.1",
-    "@vue/test-utils": "^1.0.0-beta.29",
+    "@babel/core": "^7.12.9",
+    "@babel/preset-env": "^7.12.7",
+    "@vue/test-utils": "^1.1.1",
     "babel-core": "^7.0.0-bridge.0",
-    "babel-eslint": "^10.0.3",
+    "babel-eslint": "^10.1.0",
     "babel-jest": "^24.9.0",
-    "babel-loader": "^8.0.6",
-    "copy-webpack-plugin": "^5.0.4",
+    "babel-loader": "^8.2.1",
+    "copy-webpack-plugin": "^5.1.2",
     "css-loader": "^2.1.1",
     "eslint": "^5.15.3",
-    "eslint-config-airbnb": "^18.2.0",
     "eslint-config-prettier": "^6.15.0",
     "eslint-config-standard": "^12.0.0",
-    "eslint-loader": "^2.2.1",
-    "eslint-plugin-import": "^2.18.2",
+    "eslint-plugin-import": "^2.22.1",
     "eslint-plugin-node": "^8.0.1",
     "eslint-plugin-prettier": "^3.1.4",
     "eslint-plugin-promise": "^4.2.1",
-    "eslint-plugin-react": "^7.21.5",
-    "eslint-plugin-standard": "^4.0.1",
+    "eslint-plugin-standard": "^4.1.0",
     "eslint-plugin-vue": "^5.2.3",
     "eslint-plugin-vue-a11y": "0.0.28",
+    "eslint-webpack-plugin": "^2.4.0",
     "mini-css-extract-plugin": "^0.5.0",
-    "node-sass": "^4.13.0",
+    "node-sass": "^4.14.1",
     "sass-loader": "^7.3.1",
     "style-loader": "^0.23.1",
     "uglify-es": "^3.3.9",
     "uglifyjs-webpack-plugin": "^2.2.0",
     "url-loader": "^1.1.2",
-    "vue-jest": "^3.0.5",
-    "vue-loader": "^15.7.2",
-    "vue-server-renderer": "^2.6.10",
+    "vue-jest": "^3.0.7",
+    "vue-loader": "^15.9.5",
+    "vue-server-renderer": "^2.6.12",
     "vue-style-loader": "^4.1.2",
-    "vue-template-compiler": "^2.6.10",
-    "webpack": "^4.41.2",
-    "webpack-cli": "^3.3.10",
+    "vue-template-compiler": "^2.6.12",
+    "webpack": "^4.44.2",
+    "webpack-cli": "^3.3.12",
     "webpack-merge": "^4.2.2"
   }
 }

Some files were not shown because too many files changed in this diff