lavas-project / sw-register-webpack-plugin

Lavas webpack plugin: service worker register for sw.js file no-cache solution
MIT License
37 stars 7 forks source link

not support for @vue-cli3 ? #18

Closed himself65 closed 5 years ago

himself65 commented 5 years ago

when add this plugin to vue.config.js

"C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\Yarn\bin\yarn.js" run build
yarn run v1.12.3
$ vue-cli-service build --name himself65-website --modern

(node:7340) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
(node:7340) UnhandledPromiseRejectionWarning: Error: Couldn't find preset "env" relative to directory "C:\\Users\\76128\\Desktop\\Himself65\\himself65"
    at C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
    at OptionManager.mergePresets (C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
    at OptionManager.mergeOptions (C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
    at OptionManager.init (C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (C:\Users\76128\Desktop\Himself65\himself65\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at babelCompiler (C:\Users\76128\Desktop\Himself65\himself65\node_modules\sw-register-webpack-plugin\index.js:43:18)
    at C:\Users\76128\Desktop\Himself65\himself65\node_modules\sw-register-webpack-plugin\index.js:120:15
    at _promise2.then._result2 (eval at create (C:\Users\76128\Desktop\Himself65\himself65\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:24:1)
(node:7340) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7340) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 23.58s.

Process finished with exit code 0

my config

const SwRegisterWebpackPlugin = require('sw-register-webpack-plugin')

const isPord = process.env.NODE_ENV === 'production'

module.exports = {
  assetsDir: 'public',

  pwa: {
    name: 'Himself65',
    themeColor: '#6cb2eb'
  },

  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:3001',
        changeOrigin: false
      }
    }
  },

  configureWebpack: {
    plugins: [
      new SwRegisterWebpackPlugin({
        filePath: './src/sw-register.js',
        includes: [
          'index.html',
          /^(app|chunk).+\.(js|css)$/,
          /.\.md/
        ]
      })
    ]
  }
}
{
  "name": "himself65-website",
  "private": true,
  "scripts": {
    "dev": "concurrently \" vue-cli-service serve \" \" nodemon mock/index.js \" ",
    "build": "vue-cli-service build --name himself65-website --modern",
    "inspect": "vue-cli-service inspect",
    "lint": "vue-cli-service lint",
    "test": "yarn lint"
  },
  "dependencies": {
    "@kuen/components": "^0.1.5-alpha.2",
    "@kuen/loader": "^0.1.5-alpha.2",
    "axios": "^0.18.0",
    "lodash": "^4.17.11",
    "markdown-palettes": "^0.4.6-3",
    "marked": "^0.5.2",
    "register-service-worker": "^1.5.2",
    "vue": "^2.5.17",
    "vue-aplayer": "^1.6.1",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@types/express": "^4.16.0",
    "@types/jest": "^23.3.10",
    "@types/node": "^10.12.11",
    "@types/vue": "^2.0.0",
    "@vue/cli-plugin-babel": "^3.2.0",
    "@vue/cli-plugin-eslint": "^3.2.0",
    "@vue/cli-plugin-pwa": "^3.2.0",
    "@vue/cli-service": "^3.2.0",
    "@vue/eslint-config-standard": "^4.0.0",
    "autoprefixer": "^9.4.2",
    "babel-eslint": "^10.0.1",
    "concurrently": "^4.1.0",
    "css-mqpacker": "^7.0.0",
    "eslint": "^5.8.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-node": "^8.0.0",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^5.0.0-0",
    "express": "^4.16.4",
    "mockjs": "^1.0.1-beta3",
    "nodemon": "^1.18.7",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.2",
    "sw-register-webpack-plugin": "^1.0.21",
    "vue-template-compiler": "^2.5.17"
  }
}