Forráskód Böngészése

[update] update dependencies, use webpack 4, babel 7.

oldj 7 éve
szülő
commit
0f520983d1
11 módosított fájl, 2668 hozzáadás és 1216 törlés
  1. 25 3
      .babelrc
  2. 1 1
      app-ui/events/index.js
  3. 1 1
      app/package.json
  4. 1 1
      app/ui/app.css
  5. 0 1
      app/ui/app.js
  6. 0 1
      app/ui/common.js
  7. 1 1
      app/version.js
  8. 2544 1150
      package-lock.json
  9. 34 18
      package.json
  10. 19 9
      scripts/webpack.dll.js
  11. 42 30
      webpack.config.js

+ 25 - 3
.babelrc

@@ -1,10 +1,32 @@
 {
   "presets": [
-    "latest",
-    "stage-0",
-    "react"
+    [
+      "@babel/env",
+      {
+        "modules": "commonjs",
+        "useBuiltIns": false,
+        "targets": {
+          "browsers": [
+            "Chrome >= 60",
+            "Safari >= 10.1",
+            "iOS >= 10.3",
+            "Firefox >= 54",
+            "Edge >= 15"
+          ]
+        }
+      }
+    ],
+    "@babel/react",
+    "@babel/flow"
   ],
   "plugins": [
+    "@babel/plugin-transform-async-to-generator",
+    [
+      "@babel/plugin-proposal-decorators",
+      {
+        "legacy": true
+      }
+    ],
     [
       "import",
       {

+ 1 - 1
app-ui/events/index.js

@@ -8,7 +8,7 @@
 import Agent from '../Agent'
 const req = require.context('./', false, /\.js$/)
 
-exports.reg = (app) => {
+export const reg = (app) => {
   req.keys().map(fn => {
     let m = fn.match(/^\.\/([\w\-]+)\.js$/)
     let name = m ? m[1] : null

+ 1 - 1
app/package.json

@@ -1,6 +1,6 @@
 {
   "name": "switchhosts",
-  "version": "3.3.14",
+  "version": "3.3.13",
   "description": "Switch hosts quickly!",
   "main": "main.js",
   "scripts": {

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
app/ui/app.css


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 1
app/ui/app.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 1
app/ui/common.js


+ 1 - 1
app/version.js

@@ -1 +1 @@
-exports.version = [3,3,14,5359];
+exports.version = [3,3,13,5373];

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 2544 - 1150
package-lock.json


+ 34 - 18
package.json

@@ -1,6 +1,6 @@
 {
   "name": "switchhosts",
-  "version": "3.3.14",
+  "version": "3.3.13",
   "description": "Homepage: [https://oldj.github.io/SwitchHosts/](https://oldj.github.io/SwitchHosts/)",
   "main": "",
   "scripts": {
@@ -39,23 +39,37 @@
     "react-dom": "^16.4.1"
   },
   "devDependencies": {
+    "@babel/cli": "^7.1.2",
+    "@babel/core": "^7.1.2",
+    "@babel/plugin-proposal-class-properties": "^7.1.0",
+    "@babel/plugin-proposal-decorators": "^7.1.2",
+    "@babel/plugin-proposal-do-expressions": "^7.0.0",
+    "@babel/plugin-proposal-export-default-from": "^7.0.0",
+    "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
+    "@babel/plugin-proposal-function-bind": "^7.0.0",
+    "@babel/plugin-proposal-function-sent": "^7.1.0",
+    "@babel/plugin-proposal-json-strings": "^7.0.0",
+    "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
+    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
+    "@babel/plugin-proposal-numeric-separator": "^7.0.0",
+    "@babel/plugin-proposal-optional-chaining": "^7.0.0",
+    "@babel/plugin-proposal-pipeline-operator": "^7.0.0",
+    "@babel/plugin-proposal-throw-expressions": "^7.0.0",
+    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
+    "@babel/plugin-syntax-import-meta": "^7.0.0",
+    "@babel/plugin-transform-async-to-generator": "^7.1.0",
+    "@babel/plugin-transform-object-assign": "^7.0.0",
+    "@babel/plugin-transform-runtime": "^7.1.0",
+    "@babel/polyfill": "^7.0.0",
+    "@babel/preset-env": "^7.1.0",
+    "@babel/preset-flow": "^7.0.0",
+    "@babel/preset-react": "^7.0.0",
+    "@babel/register": "^7.0.0",
     "autoprefixer": "^6.7.2",
     "ava": "^0.22.0",
-    "babel-core": "^6.26.3",
-    "babel-eslint": "^7.1.1",
-    "babel-loader": "^7.1.5",
-    "babel-plugin-import": "^1.8.0",
-    "babel-plugin-transform-class-properties": "^6.24.1",
-    "babel-plugin-transform-decorators-legacy": "^1.3.5",
-    "babel-plugin-transform-object-assign": "^6.22.0",
-    "babel-plugin-transform-runtime": "^6.23.0",
-    "babel-polyfill": "^6.26.0",
-    "babel-preset-env": "^1.7.0",
-    "babel-preset-latest": "^6.24.0",
-    "babel-preset-react": "^6.23.0",
-    "babel-preset-stage-0": "^6.22.0",
-    "babel-preset-stage-2": "^6.22.0",
-    "babel-register": "^6.26.0",
+    "babel-eslint": "^10.0.1",
+    "babel-loader": "^8.0.4",
+    "babel-plugin-import": "^1.10.0",
     "chalk": "^1.1.3",
     "classnames": "^2.2.6",
     "connect-history-api-fallback": "^1.5.0",
@@ -74,7 +88,7 @@
     "eslint-plugin-react": "^6.10.3",
     "eslint-plugin-standard": "^2.0.1",
     "eventsource-polyfill": "^0.9.6",
-    "extract-text-webpack-plugin": "^3.0.2",
+    "extract-text-webpack-plugin": "^4.0.0-beta.0",
     "file-loader": "^0.10.1",
     "friendly-errors-webpack-plugin": "^1.7.0",
     "function-bind": "^1.1.1",
@@ -98,9 +112,11 @@
     "spectron": "^3.8.0",
     "style-loader": "^0.16.1",
     "uglify-loader": "^2.0.0",
+    "uglifyjs-webpack-plugin": "^1.3.0",
     "url-loader": "^0.5.9",
-    "webpack": "^3.12.0",
+    "webpack": "^4.21.0",
     "webpack-bundle-analyzer": "^2.13.1",
+    "webpack-cli": "^3.1.2",
     "webpack-dev-middleware": "^1.12.2",
     "webpack-hot-middleware": "^2.22.2",
     "webpack-merge": "^2.6.1",

+ 19 - 9
scripts/webpack.dll.js

@@ -8,6 +8,7 @@
 const path = require('path')
 const webpack = require('webpack')
 const moment = require('moment')
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
 const basedir = path.dirname(__dirname)
 
 const vendors = [
@@ -16,6 +17,7 @@ const vendors = [
 ]
 
 module.exports = {
+  mode: 'production',
   entry: {
     'common': vendors
   },
@@ -24,16 +26,24 @@ module.exports = {
     filename: '[name].js',
     library: '[name]'
   },
+  optimization: {
+    minimizer: [
+      new UglifyJsPlugin({
+        cache: true,
+        parallel: true,
+        uglifyOptions: {
+          compress: true,
+          ecma: 6,
+          mangle: true,
+          output: {
+            ascii_only: true
+          }
+        },
+        sourceMap: true
+      })
+    ]
+  },
   plugins: [
-    new webpack.optimize.UglifyJsPlugin({
-      sourceMap: true,
-      compress: {
-        warnings: false,
-        screw_ie8: true,
-        drop_console: true,
-        drop_debugger: true
-      }
-    }),
     new webpack.DllPlugin({
       path: path.join(basedir, 'tmp', 'manifest.json'),
       name: '[name]',

+ 42 - 30
webpack.config.js

@@ -10,19 +10,21 @@ const webpack = require('webpack')
 const moment = require('moment')
 const WebpackNotifierPlugin = require('webpack-notifier')
 const ExtractTextPlugin = require('extract-text-webpack-plugin')
-const LSSPluginLists = require('less-plugin-lists')
+const LESSPluginLists = require('less-plugin-lists')
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
 const version = require('./app/version').version.join('.')
 
 module.exports = {
+  mode: 'production',
   entry: {
     app: './app-ui/index.jsx'
     //, vendor: ['react', 'antd']
   },
   devtool: 'source-map',
   output: {
-    path: path.join(__dirname, 'app', 'ui')
-    , filename: '[name].js'
-    , sourceMapFilename: '[name].js.map'
+    path: path.join(__dirname, 'app', 'ui'),
+    filename: '[name].js',
+    sourceMapFilename: '[name].js.map'
   },
   resolve: {
     extensions: ['.js', '.jsx']
@@ -32,8 +34,9 @@ module.exports = {
       {
         test: /\.jsx?$/,
         //exclude: [/node_modules/],
-        use: ['babel-loader']
-      }, {
+        use: ['babel-loader?sourceMap']
+      },
+      {
         test: /\.less$/,
         //exclude: [/node_modules/, /antd/],
         loader: ExtractTextPlugin.extract({
@@ -43,56 +46,65 @@ module.exports = {
             {
               loader: 'less-loader?outputStyle=expanded',
               options: {
+                javascriptEnabled: true,
                 plugins: [
-                  new LSSPluginLists({advanced: true})
+                  new LESSPluginLists({advanced: true})
                 ]
               }
             }
           ]
         })
-      }, {
+      },
+      {
         test: /\.css$/,
         loader: ExtractTextPlugin.extract({
           fallback: 'style-loader',
           use: 'css-loader?importLoaders=1&minimize&sourceMap'
         })
-      }, {
+      },
+      {
         test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
         use: 'url-loader?limit=30000&name=[name]-[hash].[ext]'
       }
+    ],
+    noParse: [/\bAgent\b/]
+  },
+  optimization: {
+    minimizer: [
+      new UglifyJsPlugin({
+        cache: true,
+        parallel: true,
+        uglifyOptions: {
+          compress: true,
+          ecma: 6,
+          mangle: true,
+          output: {
+            ascii_only: true
+          }
+        },
+        sourceMap: true
+      })
     ]
-    , noParse: [/\bAgent\b/]
   },
   plugins: [
     new webpack.DefinePlugin({
       'process.env': {
         NODE_ENV: JSON.stringify('production')
       }
-    })
-    //, new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'common.js'})
-    , new webpack.optimize.UglifyJsPlugin({
-      sourceMap: true,
-      compress: {
-        warnings: false
-        , drop_console: false
-      }
-      , output: {
-        comments: false
-      }
-    })
-    , new ExtractTextPlugin({
+    }),
+    new ExtractTextPlugin({
       filename: '[name].css',
       allChunks: true
-    })
-    , new webpack.DllReferencePlugin({
+    }),
+    new webpack.DllReferencePlugin({
       context: __dirname,
       manifest: require('./tmp/manifest.json')
-    })
-    , new webpack.IgnorePlugin(new RegExp('^(electron|fs|path)$'))
-    , new WebpackNotifierPlugin({
+    }),
+    new webpack.IgnorePlugin(new RegExp('^(electron|fs|path)$')),
+    new WebpackNotifierPlugin({
       title: 'SwitchHosts!',
       alwaysNotify: true
-    })
-    , new webpack.BannerPlugin(`SwitchHosts! [file] v${version}, ${moment().format('YYYY-MM-DD HH:mm:ss')}`)
+    }),
+    new webpack.BannerPlugin(`SwitchHosts! [file] v${version}, ${moment().format('YYYY-MM-DD HH:mm:ss')}`)
   ]
 }

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott