-
-
Save niwinz/671a8d53a510e0d05db7 to your computer and use it in GitHub Desktop.
js-csp using project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function build(b, debug, minify) { | |
var stream = b.bundle() | |
.on("error", function(error){ | |
console.log("~_~U Failed to generate .js files"); | |
console.error(error.toString()); | |
this.emit("end"); | |
}) | |
.pipe(source("app.js")); | |
if (debug) { | |
stream = stream.pipe(transform(function() { | |
return exorcist(APP_JS_SOURCE_MAP); | |
})); | |
} | |
const uglifyOpts = { | |
mangle: false | |
}; | |
if (minify) { | |
stream = stream.pipe(streamify(uglify(uglifyOpts))); | |
} | |
stream = stream.pipe(gulp.dest(APP_JS_ROOT)); | |
if (browserSync.active) { | |
return stream.pipe(browserSync.reload({stream: true})); | |
} | |
return stream; | |
} | |
/** | |
* Enable source watching: watch -> true | |
* Enable source minification: minify -> true | |
* Enable source maps of browserify: debug -> true | |
* Enable source maps of browserify and babel: debug -> true && sourceMaps -> true | |
**/ | |
function buildTaskFactory(options) { | |
var configFile = options.file; | |
var watch = options.watch || false; | |
var debug = options.debug || false; | |
var minify = options.minify || !debug; | |
var sourceMaps = options.sourceMaps || false; | |
return function() { | |
var b = browserify({ | |
entries: ["./src/app/proj/main"], | |
debug: debug, | |
paths: ["./src/app", "./src/vendor"], | |
cache: {}, | |
packageCache: {} | |
}); | |
if (watch) { | |
b = watchify(b, watchify.args); | |
} | |
b.transform(babelify.configure({ | |
optional: ["runtime"], | |
blacklist: ["useStrict"], | |
sourceMap: sourceMaps | |
})); | |
var aliasConfig = { | |
"aliases": { | |
"config": { | |
"relative": configFile | |
} | |
} | |
}; | |
b.transform(aliasify, aliasConfig); | |
b.on("update", function() { | |
build(b, debug || sourceMaps, minify); | |
}); | |
b.on("time", function(msg) { | |
gutil.log("Finished 'watchify' after " + (msg/1000) + " s"); | |
}); | |
return build(b, debug || sourceMaps , minify); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "proj", | |
"version": "0.0.1", | |
"description": "", | |
"main": "src/app/main.js", | |
"scripts": { | |
"test": "sh ./bin/run-test.sh" | |
}, | |
"browserify": { | |
"transform": [["babelify", { "optional": ["runtime"] }]] | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"almacen": "~0.2.0", | |
"atomo": "~0.1.2", | |
"babel-eslint": "^4.1.3", | |
"babel-runtime": "~5.8.25", | |
"babelify": "~6.3.0", | |
"baconjs": "~0.7.73", | |
"browser-sync": "^2.2.1", | |
"classnames": "^1.2.0", | |
"connect-history-api-fallback": "0.0.5", | |
"curry": "^1.2.0", | |
"immutable": "~3.6.2", | |
"intl-format-cache": "2.0.4", | |
"intl-messageformat": "1.1.0", | |
"intl-relativeformat": "1.1.0", | |
"kurtsore": "~0.1.4", | |
"leaflet": "~0.7.5", | |
"lodash": "~3.10.1", | |
"minimist": "^1.1.1", | |
"query-string": "^2.4.1", | |
"raven-js": "~1.1.22", | |
"react": "0.13.3", | |
"react-kurtsore": "~0.1.3", | |
"react-router": "^0.13.3", | |
"stompjs": "^2.3.3", | |
"superagent": "^0.21.0", | |
"transducers-js": "^0.4.174" | |
}, | |
"devDependencies": { | |
"aliasify": "~1.7.2", | |
"browserify": "~11.1.0", | |
"browserify-istanbul": "~0.2.1", | |
"chai": "~2.1.0", | |
"exorcist": "^0.4.0", | |
"gulp": "^3.9.0", | |
"gulp-csslint": "~0.2.0", | |
"gulp-eslint": "~1.0.0", | |
"gulp-jade": "~1.1.0", | |
"gulp-jsonlint": "~1.1.0", | |
"gulp-load-plugins": "~1.0.0-rc.1", | |
"gulp-rename": "~1.2.2", | |
"gulp-sourcemaps": "~1.5.2", | |
"gulp-streamify": "~1.0.2", | |
"gulp-stylus": "~2.0.7", | |
"gulp-ttf2woff": "~1.1.0", | |
"gulp-uglify": "~1.4.1", | |
"gulp-util": "~3.0.6", | |
"karma": "0.13.10", | |
"karma-browserify": "~4.4.0", | |
"karma-chai": "~0.1.0", | |
"karma-chrome-launcher": "~0.1.8", | |
"karma-coverage": "~0.2.7", | |
"karma-firefox-launcher": "~0.1.4", | |
"karma-fixture": "0.2.2", | |
"karma-html2js-preprocessor": "~0.1.0", | |
"karma-junit-reporter": "~0.2.2", | |
"karma-mocha": "~0.1.10", | |
"karma-renamer-preprocessor": "0.0.1", | |
"karma-sinon-chai": "~0.3.0", | |
"karma-slimerjs-launcher": "~0.1.2", | |
"mocha": "2.1.0", | |
"nightwatch": "~0.5.36", | |
"slimerjs": "~0.9.5", | |
"vinyl-source-stream": "~1.1.0", | |
"vinyl-transform": "~1.0.0", | |
"watchify": "^3.4.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment