diff --git a/.gitignore b/.gitignore index cee1822..efe6ff8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ node_modules # Builds dist + +package-lock.json \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..93d9f2a --- /dev/null +++ b/.npmignore @@ -0,0 +1,9 @@ +.nvmrc +lerna.json +webpack.config.js +.storybook +.idea +configs +node_modules +Makefile +src/*/src \ No newline at end of file diff --git a/.storybook/config.js b/.storybook/config.js index 9aa14c9..f0a3b0c 100644 --- a/.storybook/config.js +++ b/.storybook/config.js @@ -1,6 +1,6 @@ -import { configure } from '@storybook/react'; +import {configure} from "@storybook/react"; -const req = require.context('../src', true, /.stories.js$/); +const req = require.context("../src", true, /.stories.js$/); const loadStories = () => { req.keys().forEach((filename) => req(filename)) diff --git a/.storybook/main.js b/.storybook/main.js new file mode 100644 index 0000000..7765507 --- /dev/null +++ b/.storybook/main.js @@ -0,0 +1,7 @@ +/** + * Created by shuieryin on Jan 27 2020, 9:06 PM. + */ + +module.exports = { + addons: ["@storybook/preset-create-react-app"] +}; \ No newline at end of file diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index e36c77d..221ca79 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -1,9 +1,8 @@ -const rules = require('../configs/rules.config'); -const { aliases } = require('../configs/aliases.config'); +const {rules, aliases} = require("../configs/shared.config"); -module.exports = (baseConfig, env, defaultConfig) => { - defaultConfig.module.rules = rules; - defaultConfig.resolve.alias = aliases; +module.exports = baseConfig => { + baseConfig.config.module.rules = rules; + baseConfig.config.resolve.alias = aliases; - return defaultConfig; -}; + return baseConfig.config; +}; \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2288fa8 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +pack: + @npm run clean:components; npm run build:components; rm -rf dist; mkdir dist; npm pack; mv *.tgz dist; \ No newline at end of file diff --git a/configs/aliases.config.js b/configs/aliases.config.js deleted file mode 100644 index 8d5d00b..0000000 --- a/configs/aliases.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const path = require('path'); - -// __dirname gives exact path where the file is, in this case: PROJECT/configs. It is needed to add ../ at the beginning of the aliases to solve correct path. - -const aliases = { - '@audnavlib/button': path.resolve(__dirname, '../src/Button/src/index'), - '@audnavlib/button-group': path.resolve(__dirname, '../src/ButtonGroup/src/index'), -}; - -module.exports = { aliases }; diff --git a/configs/rules.config.js b/configs/rules.config.js deleted file mode 100644 index e93462d..0000000 --- a/configs/rules.config.js +++ /dev/null @@ -1,35 +0,0 @@ -const autoprefixer = require('autoprefixer'); - -const rules = [ - { - exclude: /node_modules/, - test: /\.(scss)$/, - use: [ - 'style-loader', - 'css-loader', - { - loader: 'postcss-loader', - options: { - plugins: [ - autoprefixer({ - grid: "autoplace", - }), - ], - }, - }, - 'sass-loader', - ], - }, - { - test: /\.(js|jsx)$/, - exclude: /node_modules/, - use: { - loader: "babel-loader", - options: { - presets: ['@babel/preset-env', '@babel/react'] - } - } - } -]; - -module.exports = rules; diff --git a/configs/shared.config.js b/configs/shared.config.js new file mode 100644 index 0000000..dd18aa0 --- /dev/null +++ b/configs/shared.config.js @@ -0,0 +1,46 @@ +const path = require("path"); +const autoprefixer = require("autoprefixer"); + +const rules = [ + { + exclude: /node_modules/, + test: /\.(scss)$/, + use: [ + "style-loader", + "css-loader", + { + loader: "postcss-loader", + options: { + plugins: [ + autoprefixer({ + grid: "autoplace" + }) + ] + } + }, + "sass-loader" + ] + }, + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: { + loader: "babel-loader", + options: { + presets: [ + "@babel/preset-env", + "@babel/react" + ] + } + } + } +]; + +// __dirname gives exact path where the file is, in this case: PROJECT/configs. It is needed to add ../ at the beginning of the aliases to solve correct path. + +const aliases = { + "@audnavlib/button": path.resolve(__dirname, "../src/Button/src/index"), + "@audnavlib/button-group": path.resolve(__dirname, "../src/ButtonGroup/src/index") +}; + +module.exports = {rules, aliases}; diff --git a/lerna.json b/lerna.json index 2d5bec5..7cb4490 100644 --- a/lerna.json +++ b/lerna.json @@ -1,12 +1,18 @@ { - "lerna": "3.13.0", + "lerna": "3.20.2", "npmClient": "npm", "version": "independent", - "packages": ["src/**/*"], + "packages": [ + "src/**/*" + ], "registry": "https://registry.npmjs.org/", "command": { "publish": { - "ignoreChanges": ["*.md", "tests/*", "ignored-files"] + "ignoreChanges": [ + "*.md", + "tests/*", + "ignored-files" + ] } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 91c4633..fb7f843 100644 --- a/package.json +++ b/package.json @@ -12,25 +12,27 @@ }, "author": "Audrius Navickas", "devDependencies": { - "@babel/core": "7.2.2", - "@babel/preset-env": "7.3.1", - "@babel/preset-react": "7.0.0", - "autoprefixer": "9.4.7", - "babel-loader": "8.0.5", - "cross-env": "5.2.0", - "css-loader": "2.1.0", - "lerna": "3.13.0", - "node-sass": "4.11.0", - "postcss-loader": "3.0.0", - "sass-loader": "7.1.0", - "style-loader": "0.23.1", - "webpack": "4.29.3", - "webpack-cli": "3.2.3" + "@babel/core": "^7.8.3", + "@babel/preset-env": "^7.8.3", + "@babel/preset-react": "^7.8.3", + "@storybook/preset-create-react-app": "^1.5.2", + "autoprefixer": "^9.7.4", + "babel-loader": "^8.0.6", + "cross-env": "^7.0.0", + "css-loader": "^3.4.2", + "lerna": "^3.20.2", + "node-sass": "^4.13.0", + "postcss-loader": "^3.0.0", + "react-scripts": "^3.3.0", + "sass-loader": "^8.0.2", + "style-loader": "^1.1.3", + "webpack": "^4.41.5", + "webpack-cli": "^3.3.10" }, "dependencies": { - "@storybook/cli": "4.1.13", - "@storybook/react": "4.1.13", - "react": "16.8.2", - "react-dom": "16.8.2" + "@storybook/cli": "5.3.9", + "@storybook/react": "5.3.9", + "react": "16.12.0", + "react-dom": "16.12.0" } } diff --git a/src/Button/package.json b/src/Button/package.json index ddddc39..e47bf01 100644 --- a/src/Button/package.json +++ b/src/Button/package.json @@ -14,7 +14,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "peerDependencies": { - "react": "^16.8.2", - "react-dom": "^16.8.2" + "react": "^16.12.0", + "react-dom": "^16.12.0" } } diff --git a/src/ButtonGroup/package.json b/src/ButtonGroup/package.json index 726e14c..9bc9f66 100644 --- a/src/ButtonGroup/package.json +++ b/src/ButtonGroup/package.json @@ -17,7 +17,7 @@ "@audnavlib/button": "^1.0.0" }, "peerDependencies": { - "react": "^16.8.2", - "react-dom": "^16.8.2" + "react": "^16.12.0", + "react-dom": "^16.12.0" } } diff --git a/webpack.config.js b/webpack.config.js index aa5afbe..fb8da44 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,20 +1,19 @@ -const pkg = require('./package.json'); -const rules = require('./configs/rules.config'); -const { aliases } = require('./configs/aliases.config'); +const pkg = require("./package.json"); +const {rules, aliases} = require("./configs/shared.config"); module.exports = { module: { rules: rules }, - entry: './src/index.js', + entry: "./src/index.js", output: { filename: pkg.main, - library: '', - libraryTarget: 'commonjs' + library: "", + libraryTarget: "commonjs2" }, resolve: { alias: aliases, - extensions: ['.js', '.jsx', '.json' ], - modules: ['node_modules'] - }, -}; + extensions: [".js", ".jsx", ".json"], + modules: ["node_modules"] + } +}; \ No newline at end of file