Skip to content

Commit d32b8ef

Browse files
author
benholloway
committed
move readme to wiki
1 parent 34f9cee commit d32b8ef

File tree

2 files changed

+16
-165
lines changed

2 files changed

+16
-165
lines changed

doc/extensibility.png

-55.6 KB
Binary file not shown.

readme.md

Lines changed: 16 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -22,185 +22,36 @@ The solution contained in this project with work with **NodeJS 4.x.x**. It is mo
2222

2323
* This package presumes [npm scripts](https://docs.npmjs.com/misc/scripts). If you want to run outside of scripts you will need some additional global installs (see below).
2424

25-
## Installation
25+
## Overview
2626

27-
Please refere to detailed [installation](https://github.com//angularity/webpack-angularity-solution/wiki/installation) instructions.
27+
This package is a singple `devDependency` that bundles together a comprehensive solution for building **AngularJS 1.x** projects.
2828

29-
## Project setup
29+
It eliminates the need to specify multiple dependencies in your root project. Unfortunately following **npm 3.x** you will still get noise from your build-system in your `/node_modules`.
3030

31-
Please refere to detailed [project setup](https://github.com//angularity/webpack-angularity-solution/wiki/project-setup) instructions.
31+
Within your `webpack.config.js` you delegate to this package. However there are a number of options that you can set, and an API for customisation of the full configuration.
3232

33-
## Usage
33+
If you wish to build a similar system for a platform other than **AngularJS 1.x**, you will find [webpack-multi-configurator](https://www.npmjs.com/package/webpack-multi-configurator) is where all the smarts are.
3434

35-
Run the `scripts` that are defined in your `package.json` by using `npm run ...`.
35+
## Reference
3636

37-
For example:
37+
### Installation
3838

39-
* run a single build using `npm run build`
39+
Please refer to detailed [installation](https://github.com//angularity/webpack-angularity-solution/wiki/installation) instructions.
4040

41-
* run a watch using `npm run watch`
41+
### Project setup
4242

43-
* run release build using `npm run release`
43+
Please refer to detailed [project setup](https://github.com//angularity/webpack-angularity-solution/wiki/project-setup) instructions.
4444

45-
### Options
45+
### Usage
4646

47-
#### General settings
47+
Usage is typically per [npm scripts](https://docs.npmjs.com/misc/scripts).
4848

49-
```javascript
50-
port : 55555, // port to serve during watch
51-
unminified: false, // switch to unminified
52-
publicPath: undefined, // CDN path for release builds
53-
globals : {}, // A hash of packages keyed by their global variable
54-
stats : { // console output
55-
hash : true,
56-
version : true,
57-
timings : true,
58-
assets : true,
59-
chunks : true,
60-
modules : true,
61-
reasons : true,
62-
children : true,
63-
source : true,
64-
errors : true,
65-
errorDetails: true,
66-
warnings : true,
67-
publicPath : true
68-
}
69-
```
49+
Please refer to detailed [usage](https://github.com//angularity/webpack-angularity-solution/wiki/usage) instructions.
7050

71-
#### Full customisation
72-
73-
These additional settings may be used to deviate from Angularity's optinionated project structure.
74-
75-
```javascript
76-
appDir : './app', // your composition roots
77-
buildDir : './app-build', // output of the app build
78-
testDir : './app-test', // output of the test build
79-
releaseDir: './app-release', // output of the release build
80-
testGlob : '**/*.spec.js' // identify your test files
81-
```
82-
83-
#### Environment variables
84-
85-
All options may be parsed from uppercase environment variables.
86-
87-
Use an underscrore to delimit camel-case, meaning `buildDir` is written as environment variable `BUILD_DIR`.
88-
89-
Use a double underscore to delimit a nested field, meaning `stats.warnings` is written as environment variable `STATS__WARNINGS`.
90-
91-
For example, to **suppress warnings** during the build:
92-
93-
```json
94-
{
95-
"scripts": {
96-
"silent": "cross-env STATS__WARNINGS=false webpack -d --progress"
97-
}
98-
}
99-
```
100-
101-
### Bower
102-
103-
Bower packages may be imported like node modules. Requiring the full module will generate code that requires each bower `main` element.
104-
105-
If it does not exist a `vendor.js` file will be **generated** in your `/app` directory if you have any Bower dependencies. This file may be ammended to fix any bad bower modules.
106-
107-
If there is a node module of the same name available then it **should** be used in preference but some edge cases exist. Best practice should ensure you do **not** have a module installed with the same name as your intended npm module. If a given module is not working as expected, build unminified and establish exactly where the module is comming from.
108-
109-
Inline loader statements (see shimming) cannot be used when requiring the bower package wholesale. If the package requires globals (such as jQuery) then then need to be set in the `globals` option. Alternatively you can import the consituent files of the package one-by-one, in which case shimming will work.
110-
111-
### Shimming
112-
113-
If a package does not export anything, or requires some global, then it may be [shimmed](https://github.com/webpack/docs/wiki/shimming-modules) on an as-used basis.
114-
115-
Since the **Angular** package does not export anything it would normally require the `export-loader?angular` statement to be used. However this is already taken care of in the common configuration and you do not need to take further action.
116-
117-
### Tests
118-
119-
Running in `test` mode will cause `test.js` file to generated in the `/app` directory. It will be composed of any Bowever `devDependencies` along with all `*.spec.js` files found in your project.
120-
121-
If it is present it will not be overwritten so you will need to manually add any new `*.spec.js` files that you create thereafter.
122-
123-
## Extensability
51+
### Customising
12452

12553
There has been a lot of effort made to ensure you can extend the Webpack configurations with your own ammendments.
12654

127-
The defined modes of `app`, `test`, and `release` each generate one or more [webpack-configurator](https://www.npmjs.com/package/webpack-configurator) instances. You will need to understand the webpack-configurator API in order to make any changes.
128-
129-
Each of these modes is defined using [webpack-multi-configurator](https://www.npmjs.com/package/webpack-multi-configurator).
130-
131-
### Existing structure
132-
133-
You should take a look at the [index.js](https://github.com/angularity/webpack-angularity-solution/blob/master/index.js) to see how the multi configurator is prepared. At the time of writing it is structured as follows.
134-
135-
![](./doc/extensibility.png)
136-
137-
For `test` and `release` there is no generator, a factory simply creates the configurator. In the case of `app` there is a generator that creates a configurator instance for each composition in the `/app` directory. Generators are passed the factory function so do not need to depend on `webpack-configurator` themselves.
138-
139-
When there are multiple compositions generated in `app`, each one of them is applied to the operations seperately. For `app` there are no additional operations, except those defined in `common`. While `test` and `release` define a single operation and then add the additional operations from `common`.
140-
141-
Finally all configurators are resolved to yield an Array of plain objects, suitable for Webpack. If you include several definitions then they will all contribute configurations to this Array.
142-
143-
### Making amendments
144-
145-
So if you want edit all modes, you would `append()` an operation to `common`. This may be done at any time before `resolve()` is called.
146-
147-
```javascript
148-
module.exports = angularity(...)
149-
.define('common')
150-
.append(additional)
151-
...
152-
.resolve();
153-
154-
function additional(configurator, options) {
155-
return configurator
156-
.merge(...);
157-
}
158-
```
159-
160-
If you wanted to edit `test`, you would `append()` an operation to `test`. This may be done at any time before `resolve()` is called.
161-
162-
```javascript
163-
module.exports = angularity(...)
164-
.define('test')
165-
.append(additional)
166-
...
167-
.resolve();
168-
169-
function additional(configurator, options) {
170-
return configurator
171-
.merge(...);
172-
}
173-
```
174-
175-
Each operation is passed the existing `configurator`, and the final (merged) `options` . It should return a configurator, usually the same instance as that provided.
176-
177-
### Custom configurator
178-
179-
If you want to add options, or change the generator, you may do so by calling the `create()` method.
180-
181-
Interestingly the export from `webpack-angularity-solution` is actually the `create()` function from an existing webpack-multi-configurator composition.
182-
183-
```javascript
184-
module.exports = angularity({...}, newFactory)
185-
...
186-
.create({...}, newerFactory)
187-
...
188-
.resolve();
189-
190-
function newFactory(internalFactory, options) {
191-
var instance = internalFactory();
192-
instance.foo = function foo(){};
193-
return instance;
194-
}
195-
196-
function newerFactory(newFactory, options) {
197-
var instance = newFactory();
198-
instance.bar = function bar(){};
199-
return instance;
200-
}
201-
202-
```
203-
204-
You may call the `create()` method at any time. The new instance will inherit all the definitions from the previous one, but none of the inclusions.
55+
There is also detailed a [configuration](https://github.com//angularity/webpack-angularity-solution/wiki/configuration) reference.
20556

206-
If you specify a new factory function it will be passed the previous `factory`, and the final (merged) `options`. In this way you can redefine the `webpack-configurator` instance to your liking.
57+
Going further there are detailed [extensibility](https://github.com//angularity/webpack-angularity-solution/wiki/configuration) instructions with examples.

0 commit comments

Comments
 (0)