mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: tweaks & fixes (#9109)
* fix: correct bundle analyzer settings * fix: svelte config fix * fix: CopyWebpackPlugin fixed ignore * chore: tabs fix
This commit is contained in:
@@ -18,6 +18,8 @@ import {
|
|||||||
getEntryDirPath,
|
getEntryDirPath,
|
||||||
getEntryPath,
|
getEntryPath,
|
||||||
} from '../helpers/platform';
|
} from '../helpers/platform';
|
||||||
|
import { getProjectRootPath } from '../helpers/project';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
|
||||||
export default function (config: Config, env: IWebpackEnv): Config {
|
export default function (config: Config, env: IWebpackEnv): Config {
|
||||||
const entryPath = getEntryPath();
|
const entryPath = getEntryPath();
|
||||||
@@ -266,7 +268,14 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
|||||||
});
|
});
|
||||||
|
|
||||||
config.when(env.report, (config) => {
|
config.when(env.report, (config) => {
|
||||||
config.plugin('BundleAnalyzerPlugin').use(BundleAnalyzerPlugin);
|
const projectRoot = getProjectRootPath();
|
||||||
|
config.plugin('BundleAnalyzerPlugin').use(BundleAnalyzerPlugin, [{
|
||||||
|
analyzerMode: 'static',
|
||||||
|
generateStatsFile: true,
|
||||||
|
openAnalyzer: false,
|
||||||
|
reportFilename: resolve(projectRoot, 'report', 'report.html'),
|
||||||
|
statsFilename: resolve(projectRoot, 'report', 'stats.json'),
|
||||||
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
// resolve .svelte files
|
// resolve .svelte files
|
||||||
// the order is reversed because we are using prepend!
|
// the order is reversed because we are using prepend!
|
||||||
config.resolve.extensions.prepend('.svelte').prepend(`.${platform}.svelte`);
|
config.resolve.extensions.prepend('.svelte').prepend(`.${platform}.svelte`);
|
||||||
|
|
||||||
// add a rule for .svelte files
|
// add a rule for .svelte files
|
||||||
config.module
|
config.module
|
||||||
.rule('svelte')
|
.rule('svelte')
|
||||||
@@ -30,7 +29,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
return {
|
return {
|
||||||
...options,
|
...options,
|
||||||
dev: !production,
|
dev: !production,
|
||||||
preprocess: [getSvelteConfigPreprocessor(), svelteNativePreprocessor()],
|
preprocess: getSvelteConfigPreprocessor(),
|
||||||
hotReload: !production,
|
hotReload: !production,
|
||||||
hotOptions: {
|
hotOptions: {
|
||||||
injectCss: false,
|
injectCss: false,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
||||||
|
import { relative, resolve } from 'path';
|
||||||
|
import { env } from '..';
|
||||||
import { getEntryDirPath } from './platform';
|
import { getEntryDirPath } from './platform';
|
||||||
|
import { getProjectRootPath } from './project';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -36,17 +38,18 @@ export function removeCopyRule(glob: string) {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export function applyCopyRules(config) {
|
export function applyCopyRules(config) {
|
||||||
|
|
||||||
|
const context = getEntryDirPath();
|
||||||
|
const projectRoot = getProjectRootPath();
|
||||||
|
const appResourcesFullPath = resolve(projectRoot, env.appResourcesPath);
|
||||||
|
const globOptions = { dot: false, ignore: [`**/${relative(context, appResourcesFullPath)}/**`] };
|
||||||
config.plugin('CopyWebpackPlugin').use(CopyWebpackPlugin, [
|
config.plugin('CopyWebpackPlugin').use(CopyWebpackPlugin, [
|
||||||
{
|
{
|
||||||
patterns: Array.from(copyRules).map((glob) => ({
|
patterns: Array.from(copyRules).map((glob) => ({
|
||||||
from: glob,
|
from: glob,
|
||||||
context: getEntryDirPath(),
|
context,
|
||||||
noErrorOnMissing: true,
|
noErrorOnMissing: true,
|
||||||
globOptions: {
|
globOptions,
|
||||||
dot: false,
|
|
||||||
// todo: ignore AppResources if inside app folder!
|
|
||||||
// ignore: [``]
|
|
||||||
},
|
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user