Skip to content

Commit

Permalink
Merge pull request #3 from magicsoup-io/feature/bundlesize
Browse files Browse the repository at this point in the history
Feature/bundlesize
  • Loading branch information
philippsiegmund authored Feb 1, 2019
2 parents 03963c5 + dae0b38 commit bc9ebda
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 37 deletions.
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage
lib
public
src
babel.config.js
CODE_OF_CONDUCT.md
CONTRIBUTING.md
styleguide.config.js
webpack.config.js
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ script:
- npm install
- npm run test
- npm run styleguide
- npm run build
- npm run build
- npm run size
1 change: 0 additions & 1 deletion __mocks__/fileMock.js

This file was deleted.

1 change: 0 additions & 1 deletion __mocks__/styleMock.js

This file was deleted.

18 changes: 12 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@magicsoup.io/stock",
"description": "The stock for our react component library soup. - 100% veggie & gluten-free",
"version": "0.0.1",
"version": "0.0.3",
"author": "zauberware",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -16,17 +16,18 @@
"email": "philipp@zauberware.com"
}
],
"dependencies": {
"styled-system": "^3.2.1"
},
"scripts": {
"start": "styleguidist server",
"prepublishOnly": "npm run build",
"styleguide": "styleguidist build",
"build": "webpack",
"build": "rm -rf dist/ && webpack",
"lint": "eslint src",
"jest": "jest --env=jsdom",
"test": "run-s lint jest"
"test": "run-s lint jest",
"size": "npx bundlesize"
},
"dependencies": {
"styled-system": "^3.2.1"
},
"devDependencies": {
"@babel/preset-env": "^7.1.0",
Expand Down Expand Up @@ -57,9 +58,12 @@
"webpack-cli": "^3.2.1"
},
"peerDependencies": {
"react": "^16.6.0",
"react-dom": "^16.6.0",
"styled-system": "^3.2.1",
"styled-components": ">=4.0.0"
},
"bugs": "https://github.com/magicsoup-io/stock/issues",
"bugs": "https://github.com/magicsoup-io/magicsoup-stock/issues",
"keywords": [
"reactjs",
"react",
Expand All @@ -72,7 +76,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/magicsoup-io/stock.git"
"url": "https://github.com/magicsoup-io/magicsoup-stock.git"
},
"husky": {
"hooks": {
Expand All @@ -89,7 +93,7 @@
"bundlesize": [
{
"path": "./dist/*.js",
"maxSize": "2 kB"
"maxSize": "1.8 kB"
}
]
}
76 changes: 57 additions & 19 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,67 @@
const path = require('path')
const webpack = require('webpack');
const pkg = require('./package.json');
const path = require('path');
const libraryName= pkg.name;

module.exports = {
entry: './src/index.js',
entry: path.join(__dirname, "./src/index.js"),
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
path: path.join(__dirname, './dist'),
filename: 'index.js',
libraryTarget: 'commonjs2',
library: libraryName,
libraryTarget: 'umd',
publicPath: '/dist/',
umdNamedDefine: true,
},
node: {
net: 'empty',
tls: 'empty',
dns: 'empty'
},
module: {
rules: [
rules : [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
exclude: /(node_modules|bower_components|dist|coverage|lib|public)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
],
test: /\.(js|jsx)$/,
use: ["babel-loader"],
include: path.resolve(__dirname, "src"),
exclude: [/node_modules/, /coverage/, /lib/, /public/],
}
]
},
externals: {
react: 'commonjs react',
resolve: {
alias: {
'react': path.resolve(__dirname, './node_modules/react') ,
'react-dom': path.resolve(__dirname, './node_modules/react-dom'),
'styled-system': path.resolve(__dirname, './node_modules/styled-system'),
'styled-components': path.resolve(__dirname, './node_modules/styled-components')
}
},
}
externals: {
// Don't bundle react, react-dom, styled-system or styled-components
react: {
commonjs: "react",
commonjs2: "react",
amd: "React",
root: "React"
},
"react-dom": {
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "ReactDOM",
root: "ReactDOM"
},
"styled-system": {
commonjs: "styled-system",
commonjs2: "styled-system",
amd: "styled-system",
root: "styled-system"
},
"styled-components": {
commonjs: "styled-components",
commonjs2: "styled-components",
amd: "styled-components",
root: "styled-components"
}
}
};

0 comments on commit bc9ebda

Please sign in to comment.