Comparing version 0.1.11 to 0.1.12
@@ -18,7 +18,17 @@ "use strict"; | ||
function ConfigRc(plugins) { | ||
var config = fs.existsSync(SPIN_CONFIG_NAME) ? | ||
JSON.parse(fs.readFileSync(SPIN_CONFIG_NAME).toString()) : pkg.spin; | ||
var config = pkg.spin ? pkg.spin : | ||
JSON.parse(fs.readFileSync(SPIN_CONFIG_NAME).toString()); | ||
if (typeof config === 'string' || (typeof config === 'object' && config.constructor === Array)) { | ||
config = { | ||
builders: (_a = {}, | ||
_a[pkg.name] = config, | ||
_a) | ||
}; | ||
} | ||
if (!config.options) { | ||
config.options = {}; | ||
} | ||
var builders = {}; | ||
for (var _i = 0, _a = Object.keys(config.builders); _i < _a.length; _i++) { | ||
var name = _a[_i]; | ||
for (var _i = 0, _b = Object.keys(config.builders); _i < _b.length; _i++) { | ||
var name = _b[_i]; | ||
var builderVal = config.builders[name]; | ||
@@ -38,4 +48,6 @@ var builder = (typeof builderVal === 'object' && builderVal.constructor !== Array) ? __assign({}, builderVal) : { stack: builderVal }; | ||
options.dllBuildDir = options.dllBuildDir || 'build/dll'; | ||
options.backendUrl = options.backendUrl || "http://{ip}:8080/graphql"; | ||
options.webpackDevPort = options.webpackDevPort || 3000; | ||
options.webpackDll = options.webpackDll !== undefined ? options.webpackDll : true; | ||
var _a; | ||
} | ||
@@ -42,0 +54,0 @@ return ConfigRc; |
@@ -30,3 +30,3 @@ "use strict"; | ||
entry: { | ||
index: ['babel-polyfill'], | ||
index: [requireModule_1.default.resolve('babel-polyfill')], | ||
}, | ||
@@ -33,0 +33,0 @@ }, builder.config); |
@@ -142,3 +142,5 @@ "use strict"; | ||
__filename: true, | ||
}, externals: requireModule_1.default('webpack-node-externals'), output: { | ||
}, externals: [requireModule_1.default('webpack-node-externals')({ | ||
whitelist: [/(^webpack|^react-native)/] | ||
})], output: { | ||
devtoolModuleFilenameTemplate: spin.dev ? '../../[resource-path]' : undefined, | ||
@@ -145,0 +147,0 @@ devtoolFallbackModuleFilenameTemplate: spin.dev ? '../../[resource-path];[hash]' : undefined, |
{ | ||
"name": "spinjs", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "compile": "tsc", |
<p align="center"><a href="#"><img width="150" src="https://rawgit.com/sysgears/spin.js/master/logo.svg"></a></p> | ||
## Spin.js - a JavaScript tool to simplify build rules development | ||
## Spin.js - is a tool that sets up great JavaScript build infrastructure for you | ||
@@ -13,11 +13,28 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/sysgears.svg?style=social)](https://twitter.com/sysgears) | ||
## Introduction | ||
## Basic Usage | ||
The idea behind `spin.js` is very simple. You add into your `package.json` the property `spin` that describes your stack: | ||
```json | ||
{ | ||
"spin": "webpack:es6:apollo:react:styled-components:sass:server" | ||
} | ||
``` | ||
and you are all set. | ||
You can then execute | ||
```bash | ||
spin watch | ||
``` | ||
to launch your project in `webpack watch` mode for development. After making changes to your code, they will be | ||
automatically reloaded from disk using Webpack Hot Module Replacement. | ||
## Usage | ||
```bash | ||
spin build | ||
``` | ||
will build your project for production environment. | ||
```bash | ||
spin --help | ||
spin test "src/**/*.spec.js" | ||
``` | ||
will run tests located in `.spec.js` files via Mocha Webpack. | ||
@@ -24,0 +41,0 @@ ## Contributors |
@@ -5,3 +5,4 @@ import * as fs from 'fs'; | ||
import Stack from './Stack'; | ||
import { Builder } from './Builder'; | ||
import {Builder} from './Builder'; | ||
const pkg = requireModule('./package.json'); | ||
@@ -12,30 +13,44 @@ | ||
export default class ConfigRc { | ||
options: any; | ||
builders: { [x: string]: Builder }; | ||
plugins: Object[]; | ||
options: any; | ||
builders: { [x: string]: Builder }; | ||
plugins: Object[]; | ||
constructor(plugins) { | ||
const config = fs.existsSync(SPIN_CONFIG_NAME) ? | ||
JSON.parse(fs.readFileSync(SPIN_CONFIG_NAME).toString()) : pkg.spin; | ||
const builders: { [x: string]: Builder } = {}; | ||
for (let name of Object.keys(config.builders)) { | ||
const builderVal = config.builders[name]; | ||
const builder: any = (typeof builderVal === 'object' && builderVal.constructor !== Array) ? | ||
{...builderVal} : {stack: builderVal}; | ||
builder.name = name; | ||
builder.stack = new Stack(config.options.stack, typeof builder === 'object' ? builder.stack : builder); | ||
builder.roles = builder.roles || ['build', 'watch']; | ||
builders[builder.name] = builder; | ||
constructor(plugins) { | ||
let config = pkg.spin ? pkg.spin : | ||
JSON.parse(fs.readFileSync(SPIN_CONFIG_NAME).toString()); | ||
if (typeof config === 'string' || (typeof config === 'object' && config.constructor === Array)) { | ||
config = { | ||
builders: { | ||
[pkg.name]: config | ||
} | ||
}; | ||
} | ||
if (!config.options) { | ||
config.options = {}; | ||
} | ||
const builders: { [x: string]: Builder } = {}; | ||
for (let name of Object.keys(config.builders)) { | ||
const builderVal = config.builders[name]; | ||
const builder: any = (typeof builderVal === 'object' && builderVal.constructor !== Array) ? | ||
{...builderVal} : {stack: builderVal}; | ||
builder.name = name; | ||
builder.stack = new Stack(config.options.stack, typeof builder === 'object' ? builder.stack : builder); | ||
builder.roles = builder.roles || ['build', 'watch']; | ||
builders[builder.name] = builder; | ||
} | ||
this.builders = builders; | ||
this.options = {...config.options}; | ||
this.plugins = plugins.concat((config.plugins || []).map(name => new (require(name)))); | ||
const options: any = this.options; | ||
options.backendBuildDir = options.backendBuildDir || 'build/server'; | ||
options.frontendBuildDir = options.frontendBuildDir || 'build/client'; | ||
options.dllBuildDir = options.dllBuildDir || 'build/dll'; | ||
options.backendUrl = options.backendUrl || "http://{ip}:8080/graphql"; | ||
options.webpackDevPort = options.webpackDevPort || 3000; | ||
options.webpackDll = options.webpackDll !== undefined ? options.webpackDll : true; | ||
} | ||
this.builders = builders; | ||
this.options = {...config.options}; | ||
this.plugins = plugins.concat((config.plugins || []).map(name => new (require(name)))); | ||
const options: any = this.options; | ||
options.backendBuildDir = options.backendBuildDir || 'build/server'; | ||
options.frontendBuildDir = options.frontendBuildDir || 'build/client'; | ||
options.dllBuildDir = options.dllBuildDir || 'build/dll'; | ||
options.webpackDevPort = options.webpackDevPort || 3000; | ||
options.webpackDll = options.webpackDll !== undefined ? options.webpackDll : true; | ||
} | ||
} |
@@ -782,3 +782,3 @@ import * as http from 'http'; | ||
const stack = builder.stack; | ||
// console.log("name: %s, config:", name, util.inspect(builder.config, false, null)); | ||
// console.log("name: %s, config:", name, require('util').inspect(builder.config, false, null)); | ||
if (stack.hasAny(['dll', 'test'])) | ||
@@ -785,0 +785,0 @@ continue; |
@@ -30,3 +30,3 @@ import requireModule from '../requireModule'; | ||
entry: { | ||
index: ['babel-polyfill'], | ||
index: [requireModule.resolve('babel-polyfill')], | ||
}, | ||
@@ -33,0 +33,0 @@ }, builder.config); |
@@ -155,3 +155,5 @@ import * as path from 'path'; | ||
}, | ||
externals: requireModule('webpack-node-externals'), | ||
externals: [requireModule('webpack-node-externals')({ | ||
whitelist: [/(^webpack|^react-native)/] | ||
})], | ||
output: { | ||
@@ -158,0 +160,0 @@ devtoolModuleFilenameTemplate: spin.dev ? '../../[resource-path]' : undefined, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
289681
4602
56