From 7d7b5aeba410c4d0e2c2147a5a31e95b61f55a64 Mon Sep 17 00:00:00 2001 From: Janette Day Date: Mon, 11 Mar 2019 13:51:49 -0500 Subject: [PATCH] Upgrade storybook to 5.0, babel 6 to babel 7 (#25) --- .babelrc | 33 +++++++++++++++++++++++--- .storybook/webpack.config.js | 45 ++++++++---------------------------- package.json | 35 ++++++++++++++++++++++------ 3 files changed, 68 insertions(+), 45 deletions(-) diff --git a/.babelrc b/.babelrc index 974a1ca..c7122c9 100755 --- a/.babelrc +++ b/.babelrc @@ -1,7 +1,34 @@ { "presets": [ - "es2015", - "stage-0", - "react" + "@babel/react", + "@babel/env" + ], + "plugins": [ + "@babel/plugin-syntax-dynamic-import", + "@babel/plugin-syntax-import-meta", + "@babel/plugin-proposal-class-properties", + "@babel/plugin-proposal-json-strings", + [ + "@babel/plugin-proposal-decorators", + { + "legacy": true + } + ], + "@babel/plugin-proposal-function-sent", + "@babel/plugin-proposal-export-namespace-from", + "@babel/plugin-proposal-numeric-separator", + "@babel/plugin-proposal-throw-expressions", + "@babel/plugin-proposal-export-default-from", + "@babel/plugin-proposal-logical-assignment-operators", + "@babel/plugin-proposal-optional-chaining", + [ + "@babel/plugin-proposal-pipeline-operator", + { + "proposal": "minimal" + } + ], + "@babel/plugin-proposal-nullish-coalescing-operator", + "@babel/plugin-proposal-do-expressions", + "@babel/plugin-proposal-function-bind" ] } diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index 7f94075..01f5db6 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -1,38 +1,13 @@ const path = require("path"); -const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js'); -module.exports = (storybookBaseConfig, configType) => { - // configType has a value of 'DEVELOPMENT' or 'PRODUCTION' - - // add our custom loaders - storybookBaseConfig.module.rules.push( - { - test: /\.css$/, - use: [ - { - loader: 'style-loader', - }, - { - loader: 'css-loader', - options: { - sourceMap: true, - }, - }, - ], - }, - { - test: /\.(woff|woff2|eot|ttf|svg)$/, - include: path.resolve(__dirname, "../src"), - use: [ - { - loader: 'url-loader', - }, - { - loader: 'file-loader', - }, - ], - } - ); - - return storybookBaseConfig; +module.exports = { + module: { + rules: [ + { + test: /\.scss$/, + loaders: ['style-loader', 'css-loader', 'sass-loader'], + include: path.resolve(__dirname, '../'), + }, + ], + }, }; diff --git a/package.json b/package.json index 17041a2..a5ff2ed 100755 --- a/package.json +++ b/package.json @@ -13,14 +13,17 @@ "lib": "npm run clean && babel src -d lib", "clean": "rm -rf lib && mkdir lib", "prepublish": "npm run lib", - "storybook": "start-storybook -p 6006" + "storybook": "NODE_PATH=src start-storybook -p 6006" }, "keywords": [ "react", "react-component" ], "dependencies": { + "@babel/core": "^7.3.4", + "babel-loader": "^8.0.5", "bootstrap": "^4.2.1", + "core-js": "^2.6.5", "excerpts": "0.0.3", "html-to-react": "^1.3.4", "prop-types": "^15.6.2", @@ -30,12 +33,30 @@ "styled-components": "^4.1.3" }, "devDependencies": { - "@storybook/react": "^3.2.4", - "babel-cli": "^6.8.0", - "babel-core": "^6.10.4", - "babel-preset-es2015": "^6.3.13", - "babel-preset-react": "^6.3.13", - "babel-preset-stage-0": "^6.3.13", + "@babel/cli": "^7.0.0", + "@babel/core": "^7.0.0", + "@babel/plugin-proposal-class-properties": "^7.0.0", + "@babel/plugin-proposal-decorators": "^7.0.0", + "@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.0.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/preset-env": "^7.0.0", + "@babel/preset-react": "^7.0.0", + "@storybook/addon-actions": "^5.0.0", + "@storybook/addon-links": "^5.0.0", + "@storybook/addons": "^5.0.0", + "@storybook/react": "^5.0.0", "css-loader": "^2.1.0", "eslint": "^5.12.1", "eslint-config-airbnb": "^17.1.0",