Build example in `example/bundle.js`

- Add watch script
- Make `npm run build` builds the example so that it’s included on npm
release
Etienne Lemay 2016-07-29 12:07:24 -04:00
parent f01ad53b6f
commit ecf3784d32
6 changed files with 38 additions and 10 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
node_modules/
build/
data/
dist/
bundle.js

View File

@ -6,6 +6,6 @@
</head>
<body>
<div></div>
<script src="../build/example.js"></script>
<script src="./bundle.js"></script>
</body>
</html>

View File

@ -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: {

View File

@ -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",

View File

@ -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(

28
scripts/watch-example.js Normal file
View File

@ -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,
})
)
})