Some updates to Node things.
This commit is contained in:
parent
df984f9ebf
commit
967d656643
@ -1,61 +1,29 @@
|
|||||||
gulp = require('gulp')
|
gulp = require('gulp')
|
||||||
browserify = require('browserify')
|
|
||||||
watchify = require('watchify')
|
|
||||||
coffeeReactify = require('coffee-reactify')
|
|
||||||
glob = require('glob')
|
glob = require('glob')
|
||||||
path = require('path')
|
path = require('path')
|
||||||
source = require('vinyl-source-stream')
|
source = require('vinyl-source-stream')
|
||||||
spawn = require('child_process').spawn
|
spawn = require('child_process').spawn
|
||||||
|
webpack = require('webpack')
|
||||||
makeBrowserify = (file) ->
|
|
||||||
[sourcePath..., _, _] = file.split(path.sep)
|
|
||||||
target = sourcePath.concat(['js', 'app.js']).join(path.sep)
|
|
||||||
|
|
||||||
b = browserify({
|
|
||||||
entries: ['./' + file]
|
|
||||||
debug: true
|
|
||||||
extensions: ['.js', '.coffee', '.cjsx']
|
|
||||||
paths: [path.join(path.sep)]
|
|
||||||
cache: {}
|
|
||||||
packageCache: {}
|
|
||||||
fullPaths: true
|
|
||||||
}).transform(coffeeReactify)
|
|
||||||
|
|
||||||
bundle = b.bundle
|
|
||||||
|
|
||||||
b.bundle = ->
|
|
||||||
console.log "Browserifying #{file}..."
|
|
||||||
|
|
||||||
bundle
|
|
||||||
.call(b)
|
|
||||||
.pipe(source(path.basename(target)))
|
|
||||||
.pipe(gulp.dest(path.dirname(target)))
|
|
||||||
|
|
||||||
b
|
|
||||||
|
|
||||||
gulp.task 'watch', ->
|
|
||||||
gulp.watch './**/sass/app.scss', ['styles']
|
|
||||||
glob '**/coffee/app.coffee', (err, files) ->
|
|
||||||
files.forEach (file) ->
|
|
||||||
b = watchify(makeBrowserify(file))
|
|
||||||
b.on 'update', b.bundle
|
|
||||||
b.bundle()
|
|
||||||
|
|
||||||
gulp.task 'styles', ->
|
|
||||||
glob '**/sass/app.scss', (err, files) ->
|
|
||||||
files.forEach (file) ->
|
|
||||||
[sourcePath..., _, _] = file.split(path.sep)
|
|
||||||
appPath = sourcePath.join(path.sep)
|
|
||||||
child = spawn 'bundle', [
|
|
||||||
'exec', 'compass', 'compile',
|
|
||||||
appPath, file, '--css-dir', 'css'
|
|
||||||
]
|
|
||||||
child.stdout.pipe(process.stdout)
|
|
||||||
child.stderr.pipe(process.stderr)
|
|
||||||
|
|
||||||
gulp.task 'scripts', ->
|
gulp.task 'scripts', ->
|
||||||
glob '**/coffee/app.coffee', (err, files) ->
|
glob './themes/**/coffee/app.coffee', (err, files) ->
|
||||||
files.forEach (file) ->
|
files.forEach (file) ->
|
||||||
makeBrowserify(file).bundle()
|
parts = file.split(path.sep)
|
||||||
|
context = path.resolve(parts.slice(0, -1).join(path.sep))
|
||||||
|
entry = ['.'].concat(parts.slice(-1)).join(path.sep)
|
||||||
|
|
||||||
|
outputPath = path.resolve(parts.slice(0, -2).concat(['js']).join(path.sep))
|
||||||
|
|
||||||
|
console.log context
|
||||||
|
console.log entry
|
||||||
|
console.log outputPath
|
||||||
|
|
||||||
|
compiler = webpack(
|
||||||
|
entry: entry
|
||||||
|
context: context
|
||||||
|
output:
|
||||||
|
path: outputPath
|
||||||
|
filename: 'app.js'
|
||||||
|
)
|
||||||
|
|
||||||
gulp.task 'default', ['watch']
|
gulp.task 'default', ['watch']
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"engines": { "node": ">=0.12" },
|
"engines": {
|
||||||
|
"node": ">=0.12"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
@ -11,11 +13,14 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"browserify": "^9.0.8",
|
"browserify": "^9.0.8",
|
||||||
|
"cjsx-loader": "^2.0.1",
|
||||||
"coffee-reactify": "^3.0.0",
|
"coffee-reactify": "^3.0.0",
|
||||||
"coffee-script": "^1.9.2",
|
"coffee-script": "^1.9.2",
|
||||||
"glob": "^5.0.5",
|
"glob": "^5.0.5",
|
||||||
"gulp": "^3.8.11",
|
"gulp": "^3.8.11",
|
||||||
|
"node-libs-browser": "^0.5.2",
|
||||||
"vinyl-source-stream": "^1.1.0",
|
"vinyl-source-stream": "^1.1.0",
|
||||||
"watchify": "^3.2.0"
|
"watchify": "^3.2.0",
|
||||||
|
"webpack": "^1.9.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user