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

Commit

Permalink
fix(copy): Resolve race condition in copy task, move to glob config
Browse files Browse the repository at this point in the history
fix(copy): Resolve race condition in copy task, move to glob config
  • Loading branch information
danbucholtz authored Dec 7, 2016
1 parent f42c980 commit cc99a73
Show file tree
Hide file tree
Showing 10 changed files with 593 additions and 269 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,18 @@ npm run build --rollup ./config/rollup.config.js

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.

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

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`.

Expand Down
54 changes: 20 additions & 34 deletions config/copy.config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@

// https://www.npmjs.com/package/fs-extra

// this is a custom dictionary to make it easy to extend/override
// provide a name for an entry, it can be anything such as 'copyAssets' or 'copyFonts'
// then provide an object with a `src` array of globs and a `dest` string
module.exports = {
include: [
{
src: '{{SRC}}/assets/',
dest: '{{WWW}}/assets/'
},
{
src: '{{SRC}}/index.html',
dest: '{{WWW}}/index.html'
},
{
src: '{{SRC}}/manifest.json',
dest: '{{WWW}}/manifest.json'
},
{
src: '{{SRC}}/service-worker.js',
dest: '{{WWW}}/service-worker.js'
},
{
src: 'node_modules/ionic-angular/polyfills/polyfills.js',
dest: '{{BUILD}}/polyfills.js'
},
{
src: 'node_modules/ionicons/dist/fonts/',
dest: '{{WWW}}/assets/fonts/'
},
{
src: 'node_modules/ionic-angular/fonts/',
dest: '{{WWW}}/assets/fonts/'
}
]
};
copyAssets: {
src: ['{{SRC}}/assets/**/*'],
dest: '{{WWW}}/assets'
},
copyIndexContent: {
src: ['{{SRC}}/index.html', '{{SRC}}/manifest.json', '{{SRC}}/service-worker.js'],
dest: '{{WWW}}'
},
copyFonts: {
src: ['{{ROOT}}/node_modules/ionicons/dist/fonts/**/*', '{{ROOT}}/node_modules/ionic-angular/fonts/**/*'],
dest: '{{WWW}}/assets/fonts'
},
copyPolyfills: {
src: ['{{ROOT}}/node_modules/ionic-angular/polyfills/polyfills.js'],
dest: '{{BUILD}}'
}
}
31 changes: 10 additions & 21 deletions config/watch.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,16 @@ var watch = require('../dist/watch');
var copy = require('../dist/copy');
var copyConfig = require('./copy.config');


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

module.exports = {

watchers: [

{
paths: [
'{{SRC}}/**/*.(ts|html|scss)'
],
options: { ignored: ['{{SRC}}/**/*.spec.ts', '**/*.DS_Store'] },
callback: watch.buildUpdate
},

{
paths: copyConfig.include.map(f => f.src),
options: { ignored: '**/*.DS_Store' },
callback: copy.copyUpdate
}

]

};
srcFiles: {
paths: ['{{SRC}}/**/*.(ts|html|scss)'],
options: { ignored: ['{{SRC}}/**/*.spec.ts', '**/*.DS_Store'] },
callback: watch.buildUpdate
},
copyConfig: copy.copyConfigToWatchConfig()
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"cross-spawn": "4.0.0",
"express": "4.14.0",
"fs-extra": "0.30.0",
"glob": "^7.1.1",
"json-loader": "0.5.4",
"node-sass": "3.10.1",
"os-name": "2.0.1",
Expand Down Expand Up @@ -73,6 +74,7 @@
"@types/clean-css": "^3.4.29",
"@types/express": "^4.0.33",
"@types/fs-extra": "^0.0.33",
"@types/glob": "^5.0.30",
"@types/jasmine": "^2.2.33",
"@types/mock-fs": "^3.6.29",
"@types/node": "^6.0.38",
Expand Down
Loading

0 comments on commit cc99a73

Please sign in to comment.