From 0b604c4c7f347802258ee89f97b552c09a981595 Mon Sep 17 00:00:00 2001 From: xiaoiver Date: Wed, 29 Nov 2017 00:09:38 +0800 Subject: [PATCH] fix: use babel-preset target current --- .babelrc | 2 +- core/utils/workbox.js | 10 +++++++--- core/webpack.js | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.babelrc b/.babelrc index 9e8651a..d7b0a80 100644 --- a/.babelrc +++ b/.babelrc @@ -4,7 +4,7 @@ "env", { "targets": { - "node": 4 + "node": "current", } } ], diff --git a/core/utils/workbox.js b/core/utils/workbox.js index 3675415..8ba7616 100644 --- a/core/utils/workbox.js +++ b/core/utils/workbox.js @@ -2,7 +2,9 @@ * @file utils.workbox.js * @author lavas */ -import {version} from 'workbox-sw/package.json'; +import {basename} from 'path'; + +export const WORKBOX_PATH = require.resolve('workbox-sw'); /** * get workbox files @@ -11,8 +13,10 @@ import {version} from 'workbox-sw/package.json'; * @return {Array} files .js & .map */ export function getWorkboxFiles(isProd) { + let filename = isProd + ? basename(WORKBOX_PATH) : basename(WORKBOX_PATH).replace('prod', 'dev'); return [ - `workbox-sw.${isProd ? 'prod' : 'dev'}.v${version}.js`, - `workbox-sw.${isProd ? 'prod' : 'dev'}.v${version}.js.map` + filename, + `${filename}.map` ]; } diff --git a/core/webpack.js b/core/webpack.js index b679238..14a8e7c 100644 --- a/core/webpack.js +++ b/core/webpack.js @@ -20,7 +20,7 @@ import WorkboxWebpackPlugin from 'workbox-webpack-plugin'; import {vueLoaders, styleLoaders} from './utils/loader'; import {assetsPath} from './utils/path'; -import {getWorkboxFiles} from './utils/workbox'; +import {WORKBOX_PATH, getWorkboxFiles} from './utils/workbox'; import {LAVAS_DIRNAME_IN_DIST, SERVER_BUNDLE, ASSETS_DIRNAME_IN_DIST} from './constants'; import fs from 'fs'; @@ -268,8 +268,6 @@ export default class WebpackConfig { }]; // Copy workbox.dev|prod.js from node_modules manually. if (this.isProd && workboxConfig) { - // node_modules/workbox-sw/build/importScripts/workbox-sw.prod.v2.1.2.js - const WORKBOX_PATH = require.resolve('workbox-sw'); copyList = copyList.concat( getWorkboxFiles(this.isProd) .map(f => {