Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #117 from Automattic/update/webpack-build-system
Browse files Browse the repository at this point in the history
Use webpack to build final product
  • Loading branch information
retrofox committed Nov 19, 2015
2 parents 0edca41 + c77b18d commit aa6718a
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 4,955 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"blacklist": [ "strict" ]
"blacklist": [ "strict" ],
"sourceMaps": "true"
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ npm-debug.log
/gh-tmp
.DS_Store
.idea
/dist
!/dist/wpcom.js
!/dist/wpcom.js.map
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,43 @@ BIN := $(THIS_DIR)/node_modules/.bin
NODE ?= node
NPM ?= $(NODE) $(shell which npm)
MOCHA ?= $(NODE) $(BIN)/mocha
BROWSERIFY ?= $(NODE) $(BIN)/browserify
BABEL ?= $(NODE) $(BIN)/babel
WEBPACK ?= $(NODE) $(BIN)/webpack

standalone: dist/wpcom.js

install: node_modules

clean:
@rm -rf node_modules dist
@rm -rf dist

distclean: clean
@rm -rf node_modules

dist: dist/lib dist/test
@mkdir -p $@

dist/lib: dist/lib/util
@mkdir -p $@

dist/lib/util:
@mkdir -p $@

dist:
dist/test:
@mkdir -p $@

dist/wpcom.js: node_modules *.js dist lib/*.js
@$(BROWSERIFY) -s WPCOM . > $@
dist/wpcom.js: *.js dist lib/*.js
@$(WEBPACK) -p --config webpack.config.js

node_modules: package.json
@NODE_ENV= $(NPM) install
@touch node_modules
babelify: dist
@$(BABEL) index.js --out-file dist/index.js
@$(BABEL) lib --out-dir dist/lib
@$(BABEL) lib/util --out-dir dist/lib/util
@$(BABEL) test --out-dir dist/test

example-server:
cd examples/server/; $(NPM) install
$(NODE) examples/server/index.js

example-browser-cors: all
cd examples/browser-cors/; $(NPM) install
$(NODE) examples/browser-cors/index.js

test: node_modules
test: babelify
@$(MOCHA) \
--compilers js:babel/register \
--timeout 120s \
Expand All @@ -46,12 +55,15 @@ test: node_modules
--bail \
--reporter spec

test-all: node_modules
test-all: babelify
@$(MOCHA) \
--compilers js:babel/register \
--timeout 120s \
--slow 3s \
--bail \
--reporter spec

.PHONY: all standalone install clean test test-all
publish: clean standalone
$(NPM) publish

.PHONY: all standalone clean distclean babelify example-server example-browser-cors test test-all publish
4 changes: 3 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ blog.posts({ number: 8 })

### Browser

Include `dist/wpcom.js` in a `<script>` tag:
Include `dist/wpcom.js` and a suitable browser shim if needed
to support the ES2015 features in `<script>` tags:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser-polyfill.js"></script>
<script src="wpcom.js"></script>
<script>
var wpcom = WPCOM('<your-token>');
Expand Down
Loading

0 comments on commit aa6718a

Please sign in to comment.