Skip to content

Commit 48a332b

Browse files
authored
chore: prepare first release 0.1.0 (#19)
1 parent 5a130cb commit 48a332b

File tree

5 files changed

+64
-119
lines changed

5 files changed

+64
-119
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ build
55
coverage
66
.nyc_output
77
yarn-error.log
8+
dist

.packito.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"remove": {
3+
"devDependencies": "*",
4+
"scripts": "*",
5+
"husky": true,
6+
"commitlint": true,
7+
"jest": true
8+
},
9+
"publisher": {
10+
"name": "yarn test"
11+
},
12+
"output": "./dist",
13+
"copy": ["README.md", "LICENSE"]
14+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"license": "MIT",
99
"scripts": {
1010
"clean": "rimraf build && mkdir build",
11-
"build": "yarn clean & cross-env NODE_ENV=production rollup -c",
11+
"build": "yarn clean & cross-env NODE_ENV=production rollup -c && packito",
1212
"build-storybook": "build-storybook -c .storybook -o public",
1313
"storybook": "start-storybook -p 9005 -c .storybook",
1414
"lint": "$(yarn bin)/eslint src",
@@ -48,6 +48,7 @@
4848
"jest": "^25.1.0",
4949
"jest-css-modules": "^2.1.0",
5050
"material-ui-popup-state": "^1.5.3",
51+
"packito": "^0.5.0",
5152
"prettier": "^1.19.1",
5253
"react-refresh": "^0.7.2",
5354
"react-test-renderer": "^16.12.0",

rollup.config.js

Lines changed: 26 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,29 @@
1-
import resolve from '@rollup/plugin-node-resolve';
21
import babel from 'rollup-plugin-babel';
3-
import { terser } from 'rollup-plugin-terser';
4-
import replace from '@rollup/plugin-replace';
5-
import url from '@rollup/plugin-url';
6-
import hotcss from 'rollup-plugin-hot-css';
7-
import copy from 'rollup-plugin-copy';
8-
9-
const appName = 'rollupReactApp';
10-
const NODE_ENV = process.env.NODE_ENV || 'development';
11-
const production = NODE_ENV !== 'development' && NODE_ENV !== 'test';
12-
const development = NODE_ENV === 'development';
13-
const outputFile = production ? '/static/js/index' : '/index.[hash]';
14-
const publicUrl = process.env.PUBLIC_URL || 'http://localhost:9000';
15-
const esmFile = `${outputFile}.js`;
16-
const iifeFile = `${outputFile}.legacy.js`;
17-
const styles = development ? '/styles.[hash].css' : 'static/assets/styles.css';
18-
19-
const genScripts = () => {
20-
let scripts = `<script async type="module" src="${esmFile}"></script>`;
21-
if (production) {
22-
scripts += `<script nomodule src="${iifeFile}"></script>`;
23-
}
24-
return scripts;
25-
};
26-
27-
const plugins = babelConf => [
28-
copy({
29-
targets: [
30-
{
31-
src: [
32-
'public/favicon.ico',
33-
'public/logo192.png',
34-
'public/logo512.png',
35-
'public/manifest.json',
36-
'public/robots.text',
37-
'public/images',
38-
],
39-
dest: 'build',
40-
},
41-
{
42-
src: 'public/index.html',
43-
dest: 'build',
44-
transform: contents =>
45-
contents
46-
.toString()
47-
.replace('%SCRIPTS%', genScripts())
48-
.replace(/%PUBLIC_URL%/g, publicUrl)
49-
.replace('%STYLES%', styles),
50-
},
51-
],
52-
}),
53-
replace({
54-
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
55-
}),
56-
url(),
57-
hotcss({
58-
hot: development,
59-
filename: development ? 'styles.css' : 'static/assets/styles.css',
60-
}),
61-
babel(babelConf),
62-
resolve({ extensions: ['.mjs', '.js', '.jsx', '.json'] }),
63-
production && terser(),
64-
];
65-
66-
const esm = {
67-
input: 'src/index.js',
68-
output: {
69-
dir: 'build',
70-
format: 'esm',
71-
entryFileNames: development ? '[name].[hash].js' : 'static/js/[name].js',
72-
assetFileNames: development ? '[name].[hash][extname]' : '[name][extname]',
73-
sourcemap: true,
74-
},
75-
plugins: plugins({
76-
exclude: 'node_modules/**',
77-
presets: [
78-
[
79-
'@babel/preset-env',
80-
{
81-
targets: {
82-
esmodules: true,
83-
},
84-
},
85-
],
86-
'@babel/preset-react',
87-
],
88-
plugins: development ? ['react-refresh/babel'] : [],
89-
}),
90-
};
2+
import resolve from '@rollup/plugin-node-resolve';
913

92-
const iife = {
93-
input: 'src/index.js',
94-
output: {
95-
dir: 'build',
96-
format: 'iife',
97-
entryFileNames: 'static/js/[name].legacy.js',
98-
assetFileNames: development ? '[name][hash][extname]' : '[name][extname]',
99-
name: appName,
100-
sourcemap: true,
101-
},
102-
plugins: plugins({
103-
presets: [
104-
[
105-
'@babel/preset-env',
106-
{
107-
targets: {
108-
browsers: ['> 0.5%'],
109-
},
110-
},
111-
],
112-
'@babel/preset-react',
113-
],
114-
}),
4+
export default {
5+
input: './src/index.js',
6+
external: [
7+
'react',
8+
'react-dom',
9+
'@material-ui/core/styles',
10+
'@material-ui/core/Slider',
11+
'@material-ui/core/Box',
12+
'@material-ui/core/Button',
13+
'@material-ui/core/Divider',
14+
'@material-ui/core/Tooltip',
15+
'@material-ui/core/TextField',
16+
'@material-ui/core/FormControl',
17+
'@material-ui/core/FormHelperText',
18+
'@material-ui/core/InputLabel',
19+
'@material-ui/core/Input',
20+
'@material-ui/core/InputAdornment',
21+
'@material-ui/core/Popover',
22+
'material-ui-popup-state',
23+
'prop-types',
24+
'react-is',
25+
'hoist-non-react-statics',
26+
],
27+
output: [{ file: './dist/index.js', format: 'esm', sourcemap: true }],
28+
plugins: [babel(), resolve({ extensions: ['.js', '.jsx'] })],
11529
};
116-
117-
const config = [esm];
118-
if (production) {
119-
config.push(iife);
120-
}
121-
export default config;

yarn.lock

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7789,6 +7789,11 @@ lodash.throttle@^4.1.1:
77897789
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
77907790
integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=
77917791

7792+
lodash.toarray@^4.4.0:
7793+
version "4.4.0"
7794+
resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"
7795+
integrity sha1-JMS/zWsvuji/0FlNsRedjptlZWE=
7796+
77927797
[email protected], lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.2.1:
77937798
version "4.17.15"
77947799
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
@@ -8315,6 +8320,13 @@ node-dir@^0.1.10:
83158320
dependencies:
83168321
minimatch "^3.0.2"
83178322

8323+
node-emoji@^1.10.0:
8324+
version "1.10.0"
8325+
resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.10.0.tgz#8886abd25d9c7bb61802a658523d1f8d2a89b2da"
8326+
integrity sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==
8327+
dependencies:
8328+
lodash.toarray "^4.4.0"
8329+
83188330
node-fetch@^1.0.1:
83198331
version "1.7.3"
83208332
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
@@ -8729,6 +8741,15 @@ p-try@^2.0.0:
87298741
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
87308742
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
87318743

8744+
packito@^0.5.0:
8745+
version "0.5.0"
8746+
resolved "https://registry.yarnpkg.com/packito/-/packito-0.5.0.tgz#0c4a108026f1a5171ad37de8a90e650845b27638"
8747+
integrity sha512-bnQvlWKomQqhYz0cy+ihU2Jud5WZaL7h+047xNrlIDvXprnS1watCaCkB89R5Fs/MNtAuy9SUf0uURkJSJ0QVA==
8748+
dependencies:
8749+
chalk "^3.0.0"
8750+
minimist "^1.2.0"
8751+
node-emoji "^1.10.0"
8752+
87328753
pako@~1.0.5:
87338754
version "1.0.11"
87348755
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"

0 commit comments

Comments
 (0)