17 changed files with 1944 additions and 58 deletions
@ -1,30 +0,0 @@ |
|||
#! /usr/bin/env node |
|||
|
|||
const { readdirSync, writeFileSync } = require('fs'); |
|||
const { resolve, join } = require('path'); |
|||
const { execSync } = require('child_process'); |
|||
const clone = require('lodash.clonedeep'); |
|||
|
|||
function writeJson(destination, content) { |
|||
writeFileSync(destination, `${JSON.stringify(content, null, 2)}\n`); |
|||
} |
|||
|
|||
const packages = resolve(__dirname, '../packages'); |
|||
|
|||
readdirSync(packages) |
|||
.map(name => { |
|||
const dir = join(packages, name); |
|||
const pkgPath = join(dir, 'package.json'); |
|||
const pkg = require(pkgPath); |
|||
const original = clone(pkg); |
|||
|
|||
Object |
|||
.keys(pkg.linkDependencies || {}) |
|||
.map(key => { |
|||
pkg.dependencies[key] = pkg.linkDependencies[key]; |
|||
}); |
|||
|
|||
writeJson(pkgPath, pkg); |
|||
execSync(`yarn publish ${dir}`, { stdio: 'inherit' }); |
|||
writeJson(pkgPath, original); |
|||
}); |
@ -1,3 +1,11 @@ |
|||
# Table of Contents |
|||
# <a href="http://neutrino.js.org"><img src="https://raw.githubusercontent.com/mozilla-neutrino/neutrino-dev/master/logo.png" height="60"></a> |
|||
|
|||
* [Readme](/README.md) |
|||
### Create and build modern JavaScript applications with zero initial configuration |
|||
#### Think: Webpack, but with presets. That's Neutrino. |
|||
|
|||
--- |
|||
|
|||
Neutrino is a companion tool which lets you build web and Node.js applications with shared presets or configurations. It intends to make the process of initializing and building projects much simpler by providing minimal development dependencies. |
|||
|
|||
Neutrino uses Webpack to build both web and Node.js projects by providing complete build presets which can be shared across targets and projects. You can use Neutrino base presets to get started building a variety of projects, create your |
|||
own presets by extending the Neutrino core ones to be shared across your own projects or even by the community. Presets can even be manipulated on a project-by-project basis to handle almost any build situation your preset doesn't cover. |
|||
|
@ -0,0 +1,12 @@ |
|||
# Summary |
|||
|
|||
* [Introduction](/README.md) |
|||
* [Installation](/installation.md) |
|||
* [Usage](/usage.md) |
|||
* [Presets](/presets/README.md) |
|||
* [Web Preset](/presets/neutrino-preset-web/README.md) |
|||
* [React Preset](/presets/neutrino-preset-react/README.md) |
|||
* [Node.js Preset](/presets/neutrino-preset-node/README.md) |
|||
* [Base Preset](/presets/neutrino-preset-base/README.md) |
|||
* [Overriding a preset](/presets/overriding-a-preset.md) |
|||
* [Creating a preset](/presets/creating-a-preset.md) |
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,38 @@ |
|||
# Installing Neutrino |
|||
|
|||
Installing Neutrino requires Node.js v6+, and either [Yarn](https://yarnpkg.com/lang/en/docs/install/) or |
|||
npm. At a minimum you will be installing Neutrino and a Neutrino preset, such as `neutrino-preset-react`. |
|||
|
|||
### Yarn Installation |
|||
|
|||
Run the following command inside your project directory. Substitute `PRESET_PKG` with the name of the preset |
|||
you wish to install. |
|||
|
|||
```bash |
|||
yarn add --dev neutrino PRESET_PKG |
|||
``` |
|||
|
|||
For example, if you wanted to build your project using Neutrino's React preset: |
|||
|
|||
```bash |
|||
yarn add --dev neutrino neutrino-preset-react |
|||
``` |
|||
|
|||
### npm Installation |
|||
|
|||
Run the following command inside your project directory. Substitute `PRESET_PKG` with the name of the preset |
|||
you wish to install. |
|||
|
|||
```bash |
|||
npm install --save-dev neutrino PRESET_PKG |
|||
``` |
|||
|
|||
For example, if you wanted to build your project using Neutrino's React preset: |
|||
|
|||
```bash |
|||
npm install --save-dev neutrino neutrino-preset-react |
|||
``` |
|||
|
|||
### Getting started |
|||
|
|||
Please continue through the documentation for instructions on Neutrino usage and default project layout. |
@ -0,0 +1,39 @@ |
|||
# What are presets? |
|||
|
|||
A preset is a Webpack- or Neutrino-compatible configuration capable of building or modifying |
|||
the build process for a project. Neutrino provides a few core presets to quickly get |
|||
started building some popular project types, but anyone can inherit, extend, and modify these |
|||
presets and tailor them to their project preferences. You can even create your own |
|||
presets from scratch. |
|||
|
|||
If you are familiar with Babel presets, Neutrino presets work similarly. For example, |
|||
given the Babel preset `babel-preset-react`, you can compile React code with JSX |
|||
to vanilla JavaScript calls. Neutrino adopts this same concept. Many more aspects of |
|||
development surround building a complete React project, for which Webpack is commonly used. |
|||
By encapsulating the common needs of a project type into a preset, Neutrino allows you to |
|||
avoid the upfront cost of configuring and instead focus on project development. |
|||
|
|||
Not every project is the same, and oftentimes small tweaks need to be made to the build |
|||
configuration in order to meet this need. Fortunately Neutrino presets can be modified and |
|||
extended directly from the project you are building. No need to be locked in to a particular |
|||
pattern, and no escape hatches that force you into maintaining the entire configuration should |
|||
you need to make changes. |
|||
|
|||
Presets can be easily distributing by publishing them to npm or GitHub and installing them |
|||
in your project. This also allows others to discover and build projects based on your own |
|||
presets. |
|||
|
|||
### Why not a boilerplate or alternative? |
|||
|
|||
Boilerplates are great resources for scaffolding out application-specific code which |
|||
would be difficult or tedious to generate for every project. Unfortunately many projects |
|||
also bake in build configuration into this process, causing a lot of duplication. If you |
|||
need to make a change to your build steps, you are forced to make that change across all |
|||
your similar projects. Using a preset rather than a boilerplate keeps this process DRY. |
|||
|
|||
Tools like [Create React App](https://github.com/facebookincubator/create-react-app) have |
|||
been fantastic improvements to the tooling ecosystem, but unfortunately only works on specific |
|||
environments like React, and do not allow simple extensibility of the build configuration. To |
|||
answer this new and similar projects are cropping up to build different types of projects, |
|||
often duplicating efforts which miss out on the best practices to share with the other project |
|||
types. |
@ -0,0 +1 @@ |
|||
# heading |
@ -0,0 +1,5 @@ |
|||
# heading |
|||
|
|||
**Important Note:** At the time of writing, Neutrino's Node preset does not support `watch` |
|||
compilation with `neutrino start`; it will instead fall back to running a build with the `NODE_ENV` |
|||
environment variable set to `development`. |
@ -0,0 +1 @@ |
|||
# heading |
@ -0,0 +1 @@ |
|||
# heading |
@ -0,0 +1,77 @@ |
|||
# Usage |
|||
|
|||
Neutrino is a command-line tool that wraps Webpack in order to support building JavaScript projects |
|||
based on shared configuration presets. You can use Neutrino within your project, preferably using |
|||
scripts defined in your project's `package.json`. |
|||
|
|||
## Setup |
|||
|
|||
After completing the [installation](/installation.md) of Neutrino and your Neutrino preset, you will |
|||
want to define some scripts in your project's `package.json` in order to simply build your project. |
|||
In a typical project: |
|||
|
|||
- `scripts.start` would be the command you wish to run during development |
|||
- `scripts.build` would be the command you wish to run to create a production bundle |
|||
- `scripts.test` would be the command you wish to run to execute tests |
|||
|
|||
Using these script targets may not be suitable for every project; know that they are just |
|||
typical recommendations for script target names, you may choose a different name if necessary |
|||
for your project. |
|||
|
|||
## Building for development |
|||
|
|||
Neutrino provides the command `neutrino start` for creating a bundle during development. Using |
|||
`neutrino start` sets the Node.js environment to `development` using the `NODE_ENV` environment variable, |
|||
which is available in your project source code. Depending on the preset you are using, `neutrino start` |
|||
may also spin up a development server with hot module reloading capabilities. |
|||
Check your preset for details. |
|||
|
|||
Usage: |
|||
|
|||
```bash |
|||
# PRESET_MODULE is the name of the preset to build with, e.g. neutrino-preset-react |
|||
neutrino start --preset PRESET_MODULE |
|||
``` |
|||
|
|||
Putting this into your `package.json` will allow you to build your project using either |
|||
`yarn start` or `npm start`. Using `neutrino-preset-react` as an example: |
|||
|
|||
```json |
|||
{ |
|||
"scripts": { |
|||
"start": "neutrino start --preset neutrino-preset-react" |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Building for production |
|||
|
|||
Neutrino provides the command `neutrino build` for creating a bundle for production deployment. |
|||
Using `neutrino build` sets the Node.js environment to `production` using the `NODE_ENV` environment variable, |
|||
which is available in your project source code. |
|||
|
|||
```bash |
|||
# PRESET_MODULE is the name of the preset to build with, e.g. neutrino-preset-react |
|||
neutrino build --preset PRESET_MODULE |
|||
``` |
|||
|
|||
Putting this into your `package.json` will allow you to build your project using either |
|||
`yarn start` or `npm start`. Using `neutrino-preset-react` as an example: |
|||
|
|||
```json |
|||
{ |
|||
"scripts": { |
|||
"start": "neutrino build --preset neutrino-preset-react" |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Building and running tests |
|||
|
|||
Neutrino provides the command `neutrino test` for creating a production bundle for use in executing tests. |
|||
Using `neutrino test` sets the Node.js environment variable to `test` using the `NODE_ENV` environment |
|||
variable, which is available in your project source code. |
|||
|
|||
|
|||
|
|||
## Default project layout |
File diff suppressed because it is too large
Loading…
Reference in new issue