mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
feat(webpack): place hidden sourceMaps in platforms folder (#10352)
This commit is contained in:
@ -648,3 +648,5 @@ exports[`base configuration support env.watchNodeModules 1`] = `
|
||||
"managedPaths": [],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`base configuration supports env.sourceMap=hidden-source-map 1`] = `"../../../ios-sourceMaps/[file].map[query]"`;
|
||||
|
@ -210,4 +210,15 @@ describe('base configuration', () => {
|
||||
|
||||
expect(config.get('profile')).toBe(true);
|
||||
});
|
||||
|
||||
it('supports env.sourceMap=hidden-source-map', () => {
|
||||
init({
|
||||
ios: true,
|
||||
sourceMap: 'hidden-source-map',
|
||||
});
|
||||
const config = base(new Config());
|
||||
|
||||
expect(config.output.get('sourceMapFilename')).toMatchSnapshot();
|
||||
expect(config.get('devtool')).toBe('hidden-source-map');
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { extname, resolve } from 'path';
|
||||
import { extname, relative, resolve } from 'path';
|
||||
import {
|
||||
ContextExclusionPlugin,
|
||||
DefinePlugin,
|
||||
@ -32,6 +32,7 @@ import {
|
||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
const entryPath = getEntryPath();
|
||||
const platform = getPlatformName();
|
||||
const outputPath = getAbsoluteDistPath();
|
||||
const mode = env.production ? 'production' : 'development';
|
||||
|
||||
// set mode
|
||||
@ -80,6 +81,15 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
|
||||
config.devtool(getSourceMapType(env.sourceMap));
|
||||
|
||||
// when using hidden-source-map, output source maps to the `platforms/{platformName}-sourceMaps` folder
|
||||
if (env.sourceMap === 'hidden-source-map') {
|
||||
const sourceMapAbsolutePath = getProjectFilePath(
|
||||
`./platforms/${platform}-sourceMaps/[file].map[query]`
|
||||
);
|
||||
const sourceMapRelativePath = relative(outputPath, sourceMapAbsolutePath);
|
||||
config.output.sourceMapFilename(sourceMapRelativePath);
|
||||
}
|
||||
|
||||
// todo: figure out easiest way to make "node" target work in ns
|
||||
// rather than the custom ns target implementation that's hard to maintain
|
||||
// appears to be working - but we still have to deal with HMR
|
||||
@ -110,7 +120,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
});
|
||||
|
||||
config.output
|
||||
.path(getAbsoluteDistPath())
|
||||
.path(outputPath)
|
||||
.pathinfo(false)
|
||||
.publicPath('')
|
||||
.libraryTarget('commonjs')
|
||||
|
Reference in New Issue
Block a user