Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit cc99a73

Browse files
authored
fix(copy): Resolve race condition in copy task, move to glob config
fix(copy): Resolve race condition in copy task, move to glob config
1 parent f42c980 commit cc99a73

File tree

10 files changed

+593
-269
lines changed

10 files changed

+593
-269
lines changed

README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,18 @@ npm run build --rollup ./config/rollup.config.js
120120

121121
These environment variables are automatically set to [Node's `process.env`](https://nodejs.org/api/process.html#process_process_env) property. These variables can be useful from within custom configuration files, such as custom `webpack.config.js` file.
122122

123-
| Environment Variable | Description |
124-
|-------------------------|----------------------------------------------------------------------|
125-
| `IONIC_ENV` | Value can be either `prod` or `dev`. |
126-
| `IONIC_ROOT_DIR` | The absolute path to the project's root directory. |
127-
| `IONIC_TMP_DIR` | The absolute path to the project's temporary directory. |
128-
| `IONIC_SRC_DIR` | The absolute path to the app's source directory. |
129-
| `IONIC_WWW_DIR` | The absolute path to the app's public distribution directory. |
130-
| `IONIC_BUILD_DIR` | The absolute path to the app's bundled js and css files. |
131-
| `IONIC_APP_SCRIPTS_DIR` | The absolute path to the `@ionic/app-scripts` node_module directory. |
132-
| `IONIC_SOURCE_MAP` | The Webpack `devtool` setting. We recommend `eval` or `source-map`. |
123+
| Environment Variable | Description |
124+
|----------------------------|----------------------------------------------------------------------|
125+
| `IONIC_ENV` | Value can be either `prod` or `dev`. |
126+
| `IONIC_ROOT_DIR` | The absolute path to the project's root directory. |
127+
| `IONIC_TMP_DIR` | The absolute path to the project's temporary directory. |
128+
| `IONIC_SRC_DIR` | The absolute path to the app's source directory. |
129+
| `IONIC_WWW_DIR` | The absolute path to the app's public distribution directory. |
130+
| `IONIC_BUILD_DIR` | The absolute path to the app's bundled js and css files. |
131+
| `IONIC_APP_SCRIPTS_DIR` | The absolute path to the `@ionic/app-scripts` node_module directory. |
132+
| `IONIC_SOURCE_MAP` | The Webpack `devtool` setting. We recommend `eval` or `source-map`. |
133+
| `IONIC_PATH_TO_GLOB_UTILS` | The path to Ionic's `glob-util` script. Used within configs. |
134+
| `IONIC_CLEAN_BEFORE_COPY` | Attempt to clean existing directories before copying files. |
133135

134136
The `process.env.IONIC_ENV` environment variable can be used to test whether it is a `prod` or `dev` build, which automatically gets set by any command. By default the `build` task is `prod`, and the `watch` and `serve` tasks are `dev`. Additionally, using the `--dev` command line flag will force the build to use `dev`.
135137

config/copy.config.js

+20-34
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
1-
2-
// https://www.npmjs.com/package/fs-extra
3-
1+
// this is a custom dictionary to make it easy to extend/override
2+
// provide a name for an entry, it can be anything such as 'copyAssets' or 'copyFonts'
3+
// then provide an object with a `src` array of globs and a `dest` string
44
module.exports = {
5-
include: [
6-
{
7-
src: '{{SRC}}/assets/',
8-
dest: '{{WWW}}/assets/'
9-
},
10-
{
11-
src: '{{SRC}}/index.html',
12-
dest: '{{WWW}}/index.html'
13-
},
14-
{
15-
src: '{{SRC}}/manifest.json',
16-
dest: '{{WWW}}/manifest.json'
17-
},
18-
{
19-
src: '{{SRC}}/service-worker.js',
20-
dest: '{{WWW}}/service-worker.js'
21-
},
22-
{
23-
src: 'node_modules/ionic-angular/polyfills/polyfills.js',
24-
dest: '{{BUILD}}/polyfills.js'
25-
},
26-
{
27-
src: 'node_modules/ionicons/dist/fonts/',
28-
dest: '{{WWW}}/assets/fonts/'
29-
},
30-
{
31-
src: 'node_modules/ionic-angular/fonts/',
32-
dest: '{{WWW}}/assets/fonts/'
33-
}
34-
]
35-
};
5+
copyAssets: {
6+
src: ['{{SRC}}/assets/**/*'],
7+
dest: '{{WWW}}/assets'
8+
},
9+
copyIndexContent: {
10+
src: ['{{SRC}}/index.html', '{{SRC}}/manifest.json', '{{SRC}}/service-worker.js'],
11+
dest: '{{WWW}}'
12+
},
13+
copyFonts: {
14+
src: ['{{ROOT}}/node_modules/ionicons/dist/fonts/**/*', '{{ROOT}}/node_modules/ionic-angular/fonts/**/*'],
15+
dest: '{{WWW}}/assets/fonts'
16+
},
17+
copyPolyfills: {
18+
src: ['{{ROOT}}/node_modules/ionic-angular/polyfills/polyfills.js'],
19+
dest: '{{BUILD}}'
20+
}
21+
}

config/watch.config.js

+10-21
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,16 @@ var watch = require('../dist/watch');
22
var copy = require('../dist/copy');
33
var copyConfig = require('./copy.config');
44

5-
5+
// this is a custom dictionary to make it easy to extend/override
6+
// provide a name for an entry, it can be anything such as 'srcFiles' or 'copyConfig'
7+
// then provide an object with the paths, options, and callback fields populated per the Chokidar docs
68
// https://www.npmjs.com/package/chokidar
79

810
module.exports = {
9-
10-
watchers: [
11-
12-
{
13-
paths: [
14-
'{{SRC}}/**/*.(ts|html|scss)'
15-
],
16-
options: { ignored: ['{{SRC}}/**/*.spec.ts', '**/*.DS_Store'] },
17-
callback: watch.buildUpdate
18-
},
19-
20-
{
21-
paths: copyConfig.include.map(f => f.src),
22-
options: { ignored: '**/*.DS_Store' },
23-
callback: copy.copyUpdate
24-
}
25-
26-
]
27-
28-
};
11+
srcFiles: {
12+
paths: ['{{SRC}}/**/*.(ts|html|scss)'],
13+
options: { ignored: ['{{SRC}}/**/*.spec.ts', '**/*.DS_Store'] },
14+
callback: watch.buildUpdate
15+
},
16+
copyConfig: copy.copyConfigToWatchConfig()
17+
};

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"cross-spawn": "4.0.0",
3939
"express": "4.14.0",
4040
"fs-extra": "0.30.0",
41+
"glob": "^7.1.1",
4142
"json-loader": "0.5.4",
4243
"node-sass": "3.10.1",
4344
"os-name": "2.0.1",
@@ -73,6 +74,7 @@
7374
"@types/clean-css": "^3.4.29",
7475
"@types/express": "^4.0.33",
7576
"@types/fs-extra": "^0.0.33",
77+
"@types/glob": "^5.0.30",
7678
"@types/jasmine": "^2.2.33",
7779
"@types/mock-fs": "^3.6.29",
7880
"@types/node": "^6.0.38",

0 commit comments

Comments
 (0)