Skip to content

Commit 3c412e8

Browse files
committed
feat(Browser): added browser build to use with a CDN
1 parent 5713419 commit 3c412e8

File tree

3 files changed

+1874
-78
lines changed

3 files changed

+1874
-78
lines changed

package.json

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
"travis-deploy-once": "travis-deploy-once",
1616
"semantic-release": "semantic-release",
1717
"prebuild": "rimraf dist",
18-
"build": "babel --copy-files --out-dir dist --ignore *.spec.js src"
18+
"build:main": "babel --copy-files --out-dir dist --ignore *.spec.js src",
19+
"build:umd": "webpack --output-filename index.umd.js",
20+
"build:umd.min": "webpack --output-filename index.umd.min.js -p",
21+
"build": "npm-run-all --parallel build:*"
1922
},
2023
"repository": {
2124
"type": "git",
@@ -44,6 +47,7 @@
4447
"babel-cli": "^6.26.0",
4548
"babel-core": "^6.26.0",
4649
"babel-jest": "^22.4.1",
50+
"babel-loader": "^7.1.4",
4751
"babel-plugin-transform-class-properties": "^6.24.1",
4852
"babel-polyfill": "^6.26.0",
4953
"babel-preset-env": "^1.6.1",
@@ -59,12 +63,14 @@
5963
"istanbul": "^0.4.5",
6064
"jest": "^22.4.2",
6165
"jest-babel": "^1.0.1",
66+
"npm-run-all": "^4.1.2",
6267
"react": "^16.2.0",
6368
"react-dom": "^16.2.0",
6469
"regenerator-runtime": "^0.11.1",
6570
"rimraf": "^2.6.2",
6671
"semantic-release": "^15.0.2",
67-
"travis-deploy-once": "^4.4.0"
72+
"travis-deploy-once": "^4.4.0",
73+
"webpack": "^4.1.1"
6874
},
6975
"peerDependencies": {
7076
"lodash": "^4.17.5",
@@ -77,5 +83,8 @@
7783
"ghooks": {
7884
"pre-commit": "yarn coverage && yarn check-coverage"
7985
}
86+
},
87+
"dependencies": {
88+
"webpack-cli": "^2.0.11"
8089
}
81-
}
90+
}

webpack.config.babel.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { join } from 'path';
2+
3+
const include = join(__dirname, 'src');
4+
5+
export default {
6+
entry: './src/index.jsx',
7+
output: {
8+
path: join(__dirname, 'dist'),
9+
libraryTarget: 'umd',
10+
library: 'reactMemoryGame',
11+
},
12+
devtool: 'source-map',
13+
module: {
14+
rules: [
15+
{
16+
test: /\.jsx?$/,
17+
loader: 'babel-loader',
18+
exclude: /node_modules/,
19+
query: {
20+
cacheDirectory: true,
21+
presets: ['react', 'env', 'stage-2'],
22+
},
23+
},
24+
{ test: /\.js$/, loader: 'babel-loader', include },
25+
{ test: /\.json$/, loader: 'babel-loader', include },
26+
],
27+
},
28+
resolve: {
29+
extensions: ['.js', '.jsx'],
30+
},
31+
};

0 commit comments

Comments
 (0)