Skip to content

Commit

Permalink
Set sourceRoot relative to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
teabyii committed Mar 31, 2018
1 parent 10c3f47 commit e614cf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ class Bundler extends EventEmitter {
const watch =
typeof options.watch === 'boolean' ? options.watch : !isProduction;
const target = options.target || 'browser';
const outDir = Path.resolve(options.outDir || 'dist');
return {
production: isProduction,
outDir: Path.resolve(options.outDir || 'dist'),
outDir: outDir,
outFile: options.outFile || '',
publicURL: publicURL,
watch: watch,
Expand All @@ -90,7 +91,9 @@ class Bundler extends EventEmitter {
rootDir: Path.dirname(this.mainFile),
sourceMaps:
typeof options.sourceMaps === 'boolean' ? options.sourceMaps : true,
sourceRoot: options.sourceRoot,
sourceRoot: options.sourceRoot
? Path.relative(outDir, Path.resolve(options.sourceRoot))
: undefined,
hmrHostname:
options.hmrHostname ||
(options.target === 'electron' ? 'localhost' : ''),
Expand Down
15 changes: 12 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ program
)
.option('--no-hmr', 'disable hot module replacement')
.option('--no-cache', 'disable the filesystem cache')
.option('--source-root <path>', 'set the URL root for sourcemaps')
.option(
'--source-root <path>',
'specifie the location for debugger to locate source'
)
.option('--no-source-maps', 'disable sourcemaps')
.option('--no-autoinstall', 'disable autoinstall')
.option(
Expand Down Expand Up @@ -85,7 +88,10 @@ program
)
.option('--no-hmr', 'disable hot module replacement')
.option('--no-cache', 'disable the filesystem cache')
.option('--source-root <path>', 'set the URL root for sourcemaps')
.option(
'--source-root <path>',
'specifie the location for debugger to locate source'
)
.option('--no-source-maps', 'disable sourcemaps')
.option('--no-autoinstall', 'disable autoinstall')
.option(
Expand Down Expand Up @@ -117,7 +123,10 @@ program
)
.option('--no-minify', 'disable minification')
.option('--no-cache', 'disable the filesystem cache')
.option('--source-root <path>', 'set the URL root for sourcemaps')
.option(
'--source-root <path>',
'specifie the location for debugger to locate source'
)
.option('--no-source-maps', 'disable sourcemaps')
.option(
'-t, --target <target>',
Expand Down

0 comments on commit e614cf5

Please sign in to comment.