Skip to content

Commit 9cc7d95

Browse files
authored
Update build process (styled-components#32)
* feat(babel): Use babel-preset-latest * feat(build): Add UMD build * feat(npm): Ignore unnecessary files Supersedes and closes styled-components#22
1 parent e7edcf2 commit 9cc7d95

File tree

4 files changed

+57
-9
lines changed

4 files changed

+57
-9
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
lib
33
npm-debug.log
4+
dist
5+
.DS_Store

.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.travis.yml
2+
appveyor.yml
3+
webpack.config.js
4+
.flowconfig
5+
.eslintrc
6+
.eslintignore

package.json

+13-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
"description": "",
55
"main": "lib/index.js",
66
"scripts": {
7-
"build": "babel --out-dir lib src",
8-
"build:watch": "npm run build -- --watch",
7+
"build": "npm run build:lib && npm run build:umd && npm run build:umd:min",
8+
"prebuild:lib": "rm -rf lib/*",
9+
"build:lib": "babel --out-dir lib src",
10+
"prebuild:umd": "rm -rf dist/*",
11+
"build:umd": "webpack --config webpack.config.js src/index.js dist/styled-components.js",
12+
"build:umd:min": "MINIFY_JS=true webpack --config webpack.config.js src/index.js dist/styled-components.min.js",
13+
"build:watch": "npm run build:lib -- --watch",
914
"test": "mocha \"./src/**/*.test.js\" --require babel-core/register",
1015
"test:watch": "npm run test -- --watch",
1116
"flow": "flow; test $? -eq 0 -o $? -eq 2",
1217
"lint": "eslint src",
13-
"prepublish": "rm -rf lib/* && npm run build"
18+
"prepublish": "npm run build"
1419
},
1520
"repository": {
1621
"type": "git",
@@ -38,12 +43,11 @@
3843
},
3944
"devDependencies": {
4045
"babel-cli": "^6.14.0",
41-
"babel-core": "^6.13.2",
4246
"babel-eslint": "^6.1.2",
47+
"babel-loader": "^6.2.5",
4348
"babel-plugin-add-module-exports": "^0.2.1",
4449
"babel-plugin-transform-flow-strip-types": "^6.14.0",
45-
"babel-preset-es2015": "^6.13.2",
46-
"babel-preset-es2016": "^6.11.3",
50+
"babel-preset-latest": "^6.14.0",
4751
"babel-preset-react": "^6.11.1",
4852
"eslint": "^3.5.0",
4953
"eslint-config-airbnb": "^11.1.0",
@@ -53,12 +57,12 @@
5357
"expect": "^1.20.2",
5458
"flow-bin": "^0.32.0",
5559
"mocha": "^3.0.2",
56-
"proxyquire": "^1.7.10"
60+
"proxyquire": "^1.7.10",
61+
"webpack": "^1.13.2"
5762
},
5863
"babel": {
5964
"presets": [
60-
"es2015",
61-
"es2016",
65+
"latest",
6266
"react"
6367
],
6468
"plugins": [

webpack.config.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const webpack = require('webpack')
2+
3+
const plugins = [
4+
new webpack.DefinePlugin({
5+
'process.env.NODE_ENV': 'production',
6+
}),
7+
]
8+
9+
if (process.env.MINIFY_JS) {
10+
plugins.push(new webpack.optimize.UglifyJsPlugin({
11+
compress: {
12+
warnings: false,
13+
},
14+
}))
15+
}
16+
17+
module.exports = {
18+
output: {
19+
library: 'styled-components',
20+
libraryTarget: 'umd',
21+
},
22+
module: {
23+
loaders: [
24+
{
25+
loader: 'babel',
26+
test: /\.js$/,
27+
exclude: /node_modules/,
28+
},
29+
{
30+
loader: 'json',
31+
test: /\.json$/,
32+
},
33+
],
34+
},
35+
plugins: plugins, // eslint-disable-line object-shorthand
36+
}

0 commit comments

Comments
 (0)