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

Commit 03565b7

Browse files
committed
feat(webpack source maps): make it easy to configure source map type
make it easy to configure source map type
1 parent 800f515 commit 03565b7

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ npm run build --rollup ./config/rollup.config.js
106106
| Config Values | NPM Config Property | Cmd-line Flag | Defaults |
107107
|-----------------|---------------------|---------------|-----------------|
108108
| bundler | `ionic_bundler` | `--bundler` | `webpack` |
109+
| source map type | `ionic_source_map` | `--sourceMap` | `eval` |
109110
| root directory | `ionic_root_dir` | `--rootDir` | `process.cwd()` |
110111
| tmp directory | `ionic_tmp_dir` | `--tmpDir` | `.tmp` |
111112
| www directory | `ionic_www_dir` | `--wwwDir` | `www` |
@@ -145,6 +146,9 @@ Example NPM Script:
145146
},
146147
```
147148

149+
## Tips
150+
1. The Webpack `devtool` setting is driven by the `ionic_source_map` variable. It defaults to `eval` for fast builds, but can provide the original source map by changing the value to `source-map`.
151+
148152

149153
## The Stack
150154

config/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = {
4949
path: '{{BUILD}}',
5050
filename: 'main.js'
5151
},
52-
devtool: 'eval',
52+
devtool: process.env.IONIC_SOURCE_MAP,
5353

5454
resolve: {
5555
extensions: ['.js', '.ts', '.json']

src/util/config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export function generateContext(context?: BuildContext): BuildContext {
4444

4545
setProcessEnvVar(ENV_VAR_APP_SCRIPTS_DIR, join(__dirname, '..', '..'));
4646

47+
const sourceMapValue = getConfigValue(context, '--sourceMap', null, ENV_VAR_SOURCE_MAP, ENV_VAR_SOURCE_MAP.toLowerCase(), 'eval');
48+
setProcessEnvVar(ENV_VAR_SOURCE_MAP, sourceMapValue);
49+
4750
if (!isValidBundler(context.bundler)) {
4851
context.bundler = bundlerStrategy(context);
4952
}
@@ -386,6 +389,7 @@ const ENV_VAR_SRC_DIR = 'IONIC_SRC_DIR';
386389
const ENV_VAR_WWW_DIR = 'IONIC_WWW_DIR';
387390
const ENV_VAR_BUILD_DIR = 'IONIC_BUILD_DIR';
388391
const ENV_VAR_APP_SCRIPTS_DIR = 'IONIC_APP_SCRIPTS_DIR';
392+
const ENV_VAR_SOURCE_MAP = 'IONIC_SOURCE_MAP';
389393

390394
export const BUNDLER_ROLLUP = 'rollup';
391395
export const BUNDLER_WEBPACK = 'webpack';

0 commit comments

Comments
 (0)