mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-02 21:21:37 +02:00
Separate build steps
This commit is contained in:
+20
-84
@@ -1,51 +1,36 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
var fs = require('fs');
|
||||
var rollup = require('rollup');
|
||||
var nodeResolve = require('rollup-plugin-node-resolve');
|
||||
var commonjs = require('rollup-plugin-commonjs');
|
||||
var json = require('rollup-plugin-json');
|
||||
var http = require('http');
|
||||
var gaze = require('gaze');
|
||||
var ecstatic = require('ecstatic');
|
||||
var glob = require('glob');
|
||||
var concat = require('concat-files');
|
||||
|
||||
function makeCSS() {
|
||||
glob('css/**/*.css', function (er, files) {
|
||||
if (er) console.error(er);
|
||||
concat(files, 'dist/iD.css', function (err) {
|
||||
if (err) console.error(err);
|
||||
console.log('css built');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var building = false;
|
||||
var cache;
|
||||
var colors = require('colors/safe');
|
||||
|
||||
var isDevelopment = process.argv[2] === 'develop';
|
||||
|
||||
if (isDevelopment) {
|
||||
build();
|
||||
makeCSS();
|
||||
var buildData = require('./build_data')(isDevelopment);
|
||||
var buildSrc = require('./build_src')(isDevelopment);
|
||||
var buildCSS = require('./build_css')(isDevelopment);
|
||||
|
||||
buildData();
|
||||
buildSrc();
|
||||
buildCSS();
|
||||
|
||||
if (isDevelopment) {
|
||||
gaze(['css/**/*.css'], function(err, watcher) {
|
||||
watcher.on('all', function() {
|
||||
makeCSS();
|
||||
buildCSS();
|
||||
});
|
||||
});
|
||||
|
||||
// gaze(['data/**/*.{js,json}'], function(err, watcher) {
|
||||
// watcher.on('all', function() {
|
||||
// build();
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
gaze(['modules/**/*.js', 'data/**/*.{js,json}'], function(err, watcher) {
|
||||
gaze(['data/**/*.{js,json}'], function(err, watcher) {
|
||||
watcher.on('all', function() {
|
||||
build();
|
||||
buildData();
|
||||
});
|
||||
});
|
||||
|
||||
gaze(['modules/**/*.js'], function(err, watcher) {
|
||||
watcher.on('all', function() {
|
||||
buildSrc();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,54 +38,5 @@ if (isDevelopment) {
|
||||
ecstatic({ root: __dirname, cache: 0 })
|
||||
).listen(8080);
|
||||
|
||||
console.log('Listening on :8080');
|
||||
|
||||
} else {
|
||||
build();
|
||||
makeCSS();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function unlink(f) {
|
||||
try { fs.unlinkSync(f); } catch (e) { /* noop */ }
|
||||
}
|
||||
|
||||
function build() {
|
||||
if (building) return;
|
||||
|
||||
// Start clean
|
||||
unlink('dist/iD.js');
|
||||
unlink('dist/iD.js.map');
|
||||
|
||||
building = true;
|
||||
console.log('Rebuilding');
|
||||
console.time('Rebuilt');
|
||||
|
||||
rollup.rollup({
|
||||
entry: './modules/id.js',
|
||||
plugins: [
|
||||
nodeResolve({
|
||||
jsnext: true, main: true, browser: false
|
||||
}),
|
||||
commonjs(),
|
||||
json()
|
||||
],
|
||||
cache: cache
|
||||
}).then(function (bundle) {
|
||||
bundle.write({
|
||||
format: 'iife',
|
||||
dest: 'dist/iD.js',
|
||||
sourceMap: true,
|
||||
useStrict: false
|
||||
});
|
||||
building = false;
|
||||
cache = bundle;
|
||||
console.timeEnd('Rebuilt');
|
||||
}, function(err) {
|
||||
building = false;
|
||||
cache = undefined;
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
console.log(colors.red('Listening on :8080'));
|
||||
}
|
||||
Reference in New Issue
Block a user