Package Exports
- webcompiler
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webcompiler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
webcompiler
Lint, type-check, compile and package JavaScript (ES6 + Flow static types + JSX), for the browser as well as the NodeJS; lint, compile, auto-prefix and minify SASS.
Prerequisites
- Facebook Flow (0.12+)
- SCSS-Lint
Important! Create a .flowconfig file at the root of your project with the following contents:
[ignore]
.*/invalidPackageJson/*
.*/test/*
[include]
[libs]
[options]
suppress_comment=.*@noflow.*
Installation
npm i webcompiler --save
Exposes 3 main functions
webJS- lints, type-checks, compiles, packages and minifies JavaScript for the browser (production ready + Source Maps)nodeJS- lints, type-checks and compiles JavaScript for NodeJSwebSASS- lints, compiles, packages, adds vendor prefixes and minifies SASS for the browser (production ready + Source Maps)
With the same signature
(inPath: string, outPath: string, onCompile: Function = Function.prototype,
callback: Function = Function.prototype, lintPaths: Array<string> = []): void;Arguments
inPath- the source file pathoutPath- the path to the compiled output fileonCompile- an optional function to execute after each successful compilationcallback- an optional function that is executed after the first successful compilation, can accept one argument - an optimized compiler function that can be used for continuous compilation of the same resource (a good candidate for use with a watcher)lintPaths- an optional array of paths to files as well as directories that you want the linter to check (the source file being compiled is included automatically)
Example usage
import {webJS} from 'webcompiler';
import watch from 'simple-recursive-watch';
webJS('lib/app.js', 'public/script.js', function () {
// notify LiveReload of the file change
lr.changed({body: {files: ['script.js']}});
}, function (compiler) {
// automatically invoke the same compiler if any of the JavaScript files change
watch('lib', 'js', compiler);
}, ['lib']);Additional info
- ESLint, babel-eslint and ESLint-plugin-React are used to lint the JavaScript
- Facebook Flow is used to type-check the JavaScript
- Babel is used to compile the JavaScript
- webpack is used to package the JavaScript
- UglifyJS 2 is used to compress the JavaScript
- SCSS-Lint is used to lint SASS
- node-sass and Import Once are used to compile SASS
- PostCSS and Autoprefixer Core are used to automatically add the browser vendor prefixes to the generated CSS
- Clean-css is used to compress the CSS