From 4f2d3301737a72fff30e91e8edd85e7d6ab08bda Mon Sep 17 00:00:00 2001 From: Stephen Li Date: Fri, 13 May 2022 06:06:21 -0400 Subject: [PATCH] Move babel config to separate file --- babel.config.js | 29 +++++++++++++++++++++++++++++ package.json | 18 ++---------------- yarn.lock | 9 ++++++++- 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 babel.config.js diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..9cea9b2 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,29 @@ +module.exports = { + presets: [ + '@babel/preset-env', + '@babel/preset-typescript', + ], + + plugins: [ + [ + '@babel/transform-runtime', + ], + [ + 'babel-plugin-root-import', + { + paths: [ + { + rootPathSuffix: './src/', + rootPathPrefix: 'src', + }, + ], + }, + ], + [ + 'transform-define', + { + 'DEFINE.IS_DEV': true, + }, + ], + ], +} diff --git a/package.json b/package.json index 06ec22d..945288a 100644 --- a/package.json +++ b/package.json @@ -25,21 +25,6 @@ "exStart": "cross-env NODE_ENV=production node -r source-map-support/register dist/example/www.js", "exAnalyze": "webpack-bundle-analyzer dist/example/public/stats.json" }, - "babel": { - "presets": [ - "@babel/preset-env", - "@babel/preset-typescript" - ], - "plugins": [ - [ - "@babel/transform-runtime" - ], - [ - "transform-define", - {} - ] - ] - }, "jest": { "bail": true, "setupFiles": [ @@ -70,7 +55,8 @@ "@typescript-eslint/eslint-plugin": "^5.10.0", "@typescript-eslint/parser": "^5.19.0", "@vue/server-renderer": "^3.2.33", - "babel-plugin-transform-define": "^2.0.0", + "babel-plugin-root-import": "^6.6.0", + "babel-plugin-transform-define": "^2.0.1", "copy-webpack-plugin": "^10.2.4", "cross-env": "^7.0.3", "css-loader": "^6.7.1", diff --git a/yarn.lock b/yarn.lock index 6bc0c8e..19e477d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2046,7 +2046,14 @@ babel-plugin-polyfill-regenerator@^0.3.0: dependencies: "@babel/helper-define-polyfill-provider" "^0.3.1" -babel-plugin-transform-define@^2.0.0: +babel-plugin-root-import@^6.6.0: + version "6.6.0" + resolved "https://registry.yarnpkg.com/babel-plugin-root-import/-/babel-plugin-root-import-6.6.0.tgz#85940840f308a8c292f66ca0b5bdd314046273ed" + integrity sha512-SPzVOHd7nDh5loZwZBxtX/oOu1MXeKjTkz+1VnnzLWC0dk8sJIGC2IDQ2uWIBjE5mUtXlQ35MTHSqN0Xn7qHrg== + dependencies: + slash "^3.0.0" + +babel-plugin-transform-define@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-define/-/babel-plugin-transform-define-2.0.1.tgz#6a34fd6ea89989feb75721ee4cce817ec779be7f" integrity sha512-7lDR1nFGSJHmhq/ScQtp9LTDmNE2yKPoLtwfiu+WQZnj84XL/J/5AZWZXwYcOwbDtUPhtg+y0yxTiP/oGDU6Kw==