Skip to content

Commit

Permalink
Build example in example/bundle.js
Browse files Browse the repository at this point in the history
- Add watch script
- Make `npm run build` builds the example so that it’s included on npm
  • Loading branch information
EtienneLem committed Jul 29, 2016
1 parent f01ad53 commit ecf3784
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,4 +1,4 @@
node_modules/
build/
data/
dist/
bundle.js
2 changes: 1 addition & 1 deletion example/index.html
Expand Up @@ -6,6 +6,6 @@
</head>
<body>
<div></div>
<script src="../build/example.js"></script>
<script src="./bundle.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions example/webpack.config.js
Expand Up @@ -3,8 +3,8 @@ var path = require('path')
module.exports = {
entry: path.resolve('example/index.js'),
output: {
path: path.resolve('build'),
filename: 'example.js',
path: path.resolve('example'),
filename: 'bundle.js',
},

module: {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -42,11 +42,13 @@
"webpack": "1.12.14"
},
"scripts": {
"clean": "rimraf build/ data/ dist/",
"clean": "rimraf data/ dist/",
"build:data": "node scripts/build-data",
"build:example": "node scripts/build-example",
"build:dist": "node scripts/build-dist",
"build": "npm run build:data && npm run build:dist",
"build": "npm run build:data && npm run build:example && npm run build:dist",
"watch:example": "node scripts/watch-example",
"watch": "npm run watch:example",
"react:clean": "rimraf node_modules/{react,react-dom,react-addons-test-utils}",
"react:14": "npm run react:clean && npm i react@^0.14 react-dom@^0.14 react-addons-test-utils@^0.14 --save-dev",
"react:15": "npm run react:clean && npm i react@^15 react-dom@^15 react-addons-test-utils@^15 --save-dev",
Expand Down
6 changes: 2 additions & 4 deletions scripts/build-example.js
@@ -1,10 +1,8 @@
var path = require('path')
var webpack = require('webpack')
var config = require('../example/webpack.config.js')

var config = require('../example/webpack.config.js'),
compiler = webpack(config)

compiler.watch({}, (err, stats) => {
webpack(config, (err, stats) => {
if (err) throw err

console.log(
Expand Down
28 changes: 28 additions & 0 deletions scripts/watch-example.js
@@ -0,0 +1,28 @@
var path = require('path')
var webpack = require('webpack')

var config = require('../example/webpack.config.js'),
compiler = webpack(config)

compiler.watch({}, (err, stats) => {
if (err) throw err

console.log(
stats.toString({
colors: true,
hash: true,
version: false,
timings: true,
assets: true,
chunks: false,
chunkModules: false,
modules: false,
children: false,
cached: false,
reasons: false,
source: false,
errorDetails: false,
chunkOrigins: false,
})
)
})

0 comments on commit ecf3784

Please sign in to comment.