Skip to content

Commit 326586d

Browse files
committed
feat: fix close bug/modify rollup config/eslint
1 parent 84376cd commit 326586d

File tree

7 files changed

+54
-64
lines changed

7 files changed

+54
-64
lines changed

.babelrc.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ module.exports = {
44
[
55
"@babel/preset-env",
66
{
7-
modules: false
7+
modules: false,
8+
"useBuiltIns": "entry",
9+
"targets": {
10+
"browsers": [
11+
"last 2 versions"
12+
]
13+
},
814
}
915
],
1016
"@babel/preset-react"
1117
],
1218
"plugins": [
1319
['@babel/proposal-class-properties', { loose: true }]
14-
// "external-helpers"
1520
],
1621
"env": {
1722
"development": {
1823
"plugins": [
1924
"react-hot-loader/babel"
2025
]
21-
},
22-
"production": {
23-
"plugins": [
24-
'@babel/plugin-external-helpers',
25-
],
2626
}
2727
}
2828
}

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ module.exports = {
103103
'class-methods-use-this': 'off',
104104
'react/prop-types': 0,
105105
'react/display-name': 'off',
106+
'no-console': ["error", { allow: ["warn", "error"] }],
106107
'prefer-destructuring': [
107108
'error',
108109
{

build/prod.conf.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const config = merge(base, {
77
index: './src/index.js'
88
},
99
output: {
10-
// libraryTarget: 'commonjs2',
10+
libraryTarget: 'commonjs2',
1111
filename: 'index.js',
1212
path: `${__dirname}/../dist`
1313
},
@@ -16,21 +16,15 @@ const config = merge(base, {
1616
{
1717
test: /\.scss$/,
1818
use: ['style-loader', {
19-
loader: 'css-loader',
20-
options: {
21-
minimizer: true
22-
}
19+
loader: 'css-loader'
2320
}, 'sass-loader']
2421
}
2522
]
2623
},
2724
externals: {
28-
react: 'React',
29-
'react-dom': 'ReactDOM',
30-
'prop-types': 'PropTypes'
31-
},
32-
optimization: {
33-
minimize: true
25+
react: 'commonjs react',
26+
'react-dom': 'commonjs react-dom',
27+
'prop-types': 'commonjs prop-types'
3428
}
3529
})
3630

package.json

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "@zzwing/react-image",
3-
"version": "0.1.3",
3+
"version": "1.0.1",
44
"description": "react image component",
55
"main": "dist/index.js",
6-
"module": "src/index.js",
6+
"module": "es/index.js",
77
"keywords": [
88
"react",
99
"image",
@@ -21,7 +21,7 @@
2121
"build:rollup": "cross-env NODE_ENV=production rollup -c",
2222
"build:webpack": "cross-env NODE_ENV=production webpack --config=./build/prod.conf.js",
2323
"dev": "cross-env NODE_ENV=development webpack-serve --config=./build/dev.conf.js --host 0.0.0.0 --port 2222",
24-
"publish": "npm publish --registry http://registry.npmjs.org --access=public"
24+
"pub": "npm run lint && npm run build:rollup && npm publish --registry http://registry.npmjs.org --access=public"
2525
},
2626
"author": "zhengzwing@gmail.com",
2727
"license": "MIT",
@@ -34,28 +34,27 @@
3434
"url": "https://github.com/zWingz/react-image/issues"
3535
},
3636
"peerDependencies": {
37+
"prop-types": ">=15.6.2",
3738
"react": ">=16.0.0",
38-
"react-dom": ">=16.0.0",
39-
"prop-types": ">=15.6.2"
39+
"react-dom": ">=16.0.0"
4040
},
4141
"devDependencies": {
42-
"@babel/core": "^7.0.0",
42+
"@babel/core": "^7.0.1",
4343
"@babel/plugin-external-helpers": "^7.0.0",
4444
"@babel/plugin-proposal-class-properties": "^7.0.0",
4545
"@babel/preset-env": "^7.0.0",
4646
"@babel/preset-react": "^7.0.0",
47-
"@mdx-js/loader": "^0.15.0-2",
48-
"@mdx-js/mdx": "^0.15.0-2",
49-
"autoprefixer": "^9.1.3",
47+
"@mdx-js/loader": "^0.15.2",
48+
"@mdx-js/mdx": "^0.15.2",
49+
"autoprefixer": "^9.1.5",
5050
"babel-eslint": "^9.0.0",
5151
"babel-loader": "^8.0.2",
52-
"babel-plugin-external-helpers": "^6.22.0",
5352
"cross-env": "^5.2.0",
5453
"css-loader": "^1.0.0",
5554
"cz-conventional-changelog": "^2.1.0",
56-
"docz": "^0.11.0",
55+
"docz": "^0.11.2",
5756
"docz-plugin-css": "^0.11.0",
58-
"docz-theme-default": "^0.11.0",
57+
"docz-theme-default": "^0.11.2",
5958
"eslint": "^5.5.0",
6059
"eslint-config-airbnb": "^17.0.0",
6160
"eslint-loader": "^2.1.0",
@@ -66,13 +65,14 @@
6665
"html-webpack-plugin": "^3.2.0",
6766
"node-sass": "^4.9.2",
6867
"postcss-loader": "^3.0.0",
69-
"react": "^16.4.2",
70-
"react-dom": "^16.4.2",
71-
"react-hot-loader": "^4.3.5",
68+
"postcss-url": "^8.0.0",
69+
"react": "^16.5.0",
70+
"react-dom": "^16.5.0",
71+
"react-hot-loader": "^4.3.6",
7272
"rollup": "^0.64.1",
73-
"rollup-plugin-babel": "^4.0.2",
73+
"rollup-plugin-babel": "^4.0.3",
7474
"rollup-plugin-commonjs": "^9.1.6",
75-
"rollup-plugin-node-resolve": "^3.3.0",
75+
"rollup-plugin-node-resolve": "^3.4.0",
7676
"rollup-plugin-peer-deps-external": "^2.2.0",
7777
"rollup-plugin-postcss": "^1.6.2",
7878
"rollup-plugin-sass": "^0.9.2",
@@ -81,7 +81,7 @@
8181
"sass-loader": "^7.0.3",
8282
"url-loader": "^1.1.1",
8383
"vue-style-loader": "^4.1.1",
84-
"webpack": "^4.17.1",
84+
"webpack": "^4.18.0",
8585
"webpack-cli": "^3.1.0",
8686
"webpack-merge": "^4.1.3",
8787
"webpack-serve": "^2.0.2"
@@ -91,7 +91,5 @@
9191
"path": "./node_modules/cz-conventional-changelog"
9292
}
9393
},
94-
"dependencies": {
95-
"optimize-css-assets-webpack-plugin": "^5.0.1"
96-
}
94+
"dependencies": {}
9795
}

rollup.config.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import resolve from 'rollup-plugin-node-resolve'
66
import url from 'rollup-plugin-url'
77
import sass from 'node-sass'
88
import autoprefixer from 'autoprefixer'
9+
import postcssurl from 'postcss-url'
910
import pkg from './package.json'
1011
const babelrc = require('./.babelrc.js')
1112
export default {
@@ -23,18 +24,17 @@ export default {
2324
plugins: [
2425
external(),
2526
postcss({
26-
preprocessor: (content, id) => new Promise((res) => {
27-
const result = sass.renderSync({ file: id })
28-
res({ code: result.css.toString() })
29-
}),
30-
plugins: [
31-
autoprefixer
32-
],
27+
preprocessor: (content, id) => new Promise(res => {
28+
const result = sass.renderSync({ file: id })
29+
res({ code: result.css.toString() })
30+
}),
31+
plugins: [autoprefixer, postcssurl({ url: 'inline' })],
32+
minimize: true,
3333
// extract: true,
3434
extensions: ['.sass', '.css']
3535
}),
3636
url({
37-
limit: 0, // inline files < 10k, copy files > 10k
37+
limit: 10 * 1024, // inline files < 10k, copy files > 10k
3838
publicPath: '/',
3939
emitFiles: true // defaults to true
4040
}),
@@ -43,11 +43,9 @@ export default {
4343
...babelrc
4444
// externalHelpers: true
4545
}),
46-
resolve(
47-
{
48-
extensions: ['.js', '.jsx', '.json']
49-
}
50-
),
46+
resolve({
47+
extensions: ['.js', '.jsx', '.json']
48+
}),
5149
commonjs()
5250
]
5351
}

src/lib/ImgPreview/ImgPreview.jsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,13 @@ export default class ImgPpreview extends React.PureComponent {
350350
_renderIcon() {
351351
return (
352352
<>
353-
<div className="img-viewer-close">
354-
<i
355-
ref={el => {
356-
this.$close = el
357-
}}
358-
className="react-image-icon"
359-
style={{ pointerEvents: 'none' }}
360-
>
353+
<div
354+
className="img-viewer-close"
355+
ref={el => {
356+
this.$close = el
357+
}}
358+
>
359+
<i className="react-image-icon" style={{ pointerEvents: 'none' }}>
361360
&#xe904;
362361
</i>
363362
</div>
@@ -411,8 +410,8 @@ export default class ImgPpreview extends React.PureComponent {
411410

412411
_renderFooter() {
413412
const {
414-
state, prev, next, rotateFnc
415-
} = this
413+
state, prev, next, rotateFnc
414+
} = this
416415
const { images, current } = state
417416
return (
418417
<>

src/style/global.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@font-face {
22
font-family: 'react-image-icon';
3-
src: url('../assets/fonts/icomoon.woff?5zyc2o') format('woff'),
4-
url('../assets/fonts/icomoon.svg?5zyc2o#icomoon') format('svg');
3+
src: url('../assets/fonts/icomoon.woff?5zyc2o') format('woff');
4+
// src: url('../assets/fonts/icomoon.svg?5zyc2o#icomoon') format('svg');
55
font-weight: normal;
66
font-style: normal;
77
}

0 commit comments

Comments
 (0)