Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include es5 versions of individual source files in build #806

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"lint": "eslint --no-eslintrc -c .eslintrc index.js src test",
"tape": "tape -r ./test/mock-browser.js -r babel-register test/*.test.js",
"coverage": "NODE_ENV=test nyc --reporter html npm run tape && opener coverage/index.html",
"build": "NODE_ENV=production browserify index.js --standalone MapboxDraw > dist/mapbox-gl-draw.js",
"build": "./scripts/build.sh",
"prepublish": "NODE_ENV=production browserify index.js --standalone MapboxDraw | uglifyjs -c -m > dist/mapbox-gl-draw.js",
"start": "node server.js"
},
Expand All @@ -45,6 +45,7 @@
"devDependencies": {
"@mapbox/mapbox-gl-draw-static-mode": "^1.0.1",
"@turf/centroid": "^6.0.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.9.1",
"babel-eslint": "^8.0.3",
"babel-plugin-__coverage__": "^11.0.0",
Expand Down
12 changes: 12 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
export NODE_ENV=production

# Create ES5 versions of each of the source files
npx babel ./src -d ./dist/

# Also create an ES5 version of the index file. It has a bunch of `require`
# statements that look like `require('./src/stuff')`; we rewrite them to
# `require('./stuff')` to fit into our new structure.
sed 's/\.\/src\//\.\//' < index.js > dist/index.js

browserify index.js --standalone MapboxDraw > dist/mapbox-gl-draw.js