Skip to content

Commit 8e4ae3f

Browse files
rxmarblesokonet
authored andcommitted
build: Use Webpack production mode during the build (react-dropzone#555)
Update webpack config and build on umd for production.
1 parent 223b946 commit 8e4ae3f

File tree

4 files changed

+38
-33
lines changed

4 files changed

+38
-33
lines changed

.github/stale.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ daysUntilClose: 7
88
exemptLabels:
99
- BREAKING CHANGE
1010
- ⚠︎ Pinned
11+
- in progress
1112
# Label to use when marking as stale
1213
staleLabel: stale
1314
# Comment to post when marking as stale. Set to `false` to disable

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"ci": "git-cz",
88
"clean": "rimraf ./dist",
99
"build": "npm run clean && npm run build:umd && npm run build:es",
10-
"build:umd": "cross-env NODE_ENV=production webpack",
10+
"build:umd": "cross-env NODE_ENV=production webpack -p",
1111
"build:es": "cross-env BABEL_ENV=es babel ./src --out-dir ./dist/es --ignore spec.js",
1212
"start": "styleguidist server",
1313
"styleguide": "styleguidist build",
@@ -27,7 +27,7 @@
2727
"size-limit": [
2828
{
2929
"path": "dist/index.js",
30-
"limit": "6 KB"
30+
"limit": "5.5 KB"
3131
},
3232
{
3333
"path": "dist/es/index.js",
@@ -67,7 +67,8 @@
6767
"Andrey Okonetchnikov <[email protected]> (http://okonet.ru)",
6868
"Mike Olson <[email protected]>",
6969
"Param Aggarwal",
70-
"Tyler Waters <[email protected]>"
70+
"Tyler Waters <[email protected]>",
71+
"Rick Markins <[email protected]>"
7172
],
7273
"license": "MIT",
7374
"peerDependencies": {

src/index.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe('Dropzone', () => {
264264
onClickOuterSpy.reset()
265265
onClickInnerSpy.reset()
266266

267-
component.find('Dropzone').simulate('click')
267+
component.find(Dropzone).simulate('click')
268268
expect(onClickOuterSpy.callCount).toEqual(0)
269269
expect(onClickInnerSpy.callCount).toEqual(1)
270270
})
@@ -277,15 +277,15 @@ describe('Dropzone', () => {
277277
</div>
278278
)
279279

280-
component.find('Dropzone').simulate('click')
280+
component.find(Dropzone).simulate('click')
281281
expect(onClickOuterSpy.callCount).toEqual(1)
282282
})
283283

284284
it('should invoke inputProps onClick if provided', done => {
285285
const inputPropsClickSpy = spy()
286286
const component = mount(<Dropzone inputProps={{ onClick: inputPropsClickSpy }} />)
287287

288-
component.find('Dropzone').simulate('click')
288+
component.simulate('click')
289289
setTimeout(() => {
290290
expect(inputPropsClickSpy.callCount).toEqual(1)
291291
done()

webpack.config.js

+30-27
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
const path = require('path')
22

3-
module.exports = {
4-
entry: './src/index.js',
5-
devtool: 'source-map',
6-
output: {
7-
path: path.resolve(__dirname, 'dist'),
8-
filename: 'index.js',
9-
libraryTarget: 'umd',
10-
library: 'Dropzone'
11-
},
12-
module: {
13-
loaders: [
14-
{
15-
include: [path.resolve(__dirname, 'src'), path.resolve(__dirname, 'examples')],
16-
test: /\.js$/,
17-
loader: 'babel-loader'
18-
}
19-
]
20-
},
21-
resolve: {
22-
// Can require('file') instead of require('file.js') etc.
23-
extensions: ['.js', '.json']
24-
},
25-
externals: {
26-
react: 'react',
27-
'prop-types': 'prop-types'
28-
},
29-
plugins: []
3+
module.exports = env => {
4+
const isProduction = env === 'production'
5+
return {
6+
entry: './src/index.js',
7+
devtool: isProduction ? 'source-map' : 'inline-source-map',
8+
output: {
9+
path: path.resolve(__dirname, 'dist'),
10+
filename: 'index.js',
11+
libraryTarget: 'umd',
12+
library: 'Dropzone'
13+
},
14+
module: {
15+
rules: [
16+
{
17+
include: [path.resolve(__dirname, 'src'), path.resolve(__dirname, 'examples')],
18+
test: /\.js$/,
19+
loader: 'babel-loader',
20+
exclude: /node_modules/
21+
}
22+
]
23+
},
24+
resolve: {
25+
// Can require('file') instead of require('file.js') etc.
26+
extensions: ['.js', '.json']
27+
},
28+
externals: {
29+
react: 'react',
30+
'prop-types': 'prop-types'
31+
}
32+
}
3033
}

0 commit comments

Comments
 (0)