mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
style: run prettier on webpack5 files
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Config from 'webpack-chain';
|
||||
|
||||
import { getEntryPath, getEntryDirPath } from "../helpers/platform";
|
||||
import { getEntryPath, getEntryDirPath } from '../helpers/platform';
|
||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import base from './base';
|
||||
@@ -36,15 +36,14 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
config.module
|
||||
.rule('hmr-core')
|
||||
.test(/\.js$/)
|
||||
.exclude
|
||||
.add(/node_modules/)
|
||||
.exclude.add(/node_modules/)
|
||||
.add(entryPath)
|
||||
.end()
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
appPath: getEntryDirPath()
|
||||
})
|
||||
appPath: getEntryDirPath(),
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -53,14 +53,12 @@ function getSvelteConfigPreprocessor(): any {
|
||||
}
|
||||
|
||||
interface ISvelteConfig {
|
||||
preprocess: any
|
||||
preprocess: any;
|
||||
}
|
||||
|
||||
function getSvelteConfig(): ISvelteConfig | undefined {
|
||||
try {
|
||||
return require(
|
||||
getProjectFilePath('svelte.config.js')
|
||||
) as ISvelteConfig;
|
||||
return require(getProjectFilePath('svelte.config.js')) as ISvelteConfig;
|
||||
} catch (err) {
|
||||
error('Could not find svelte.config.js.', err);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Config from 'webpack-chain';
|
||||
|
||||
import { getEntryDirPath, getEntryPath } from "../helpers/platform";
|
||||
import { getEntryDirPath, getEntryPath } from '../helpers/platform';
|
||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import base from './base';
|
||||
@@ -36,15 +36,14 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
config.module
|
||||
.rule('hmr-core')
|
||||
.test(/\.(js|ts)$/)
|
||||
.exclude
|
||||
.add(/node_modules/)
|
||||
.exclude.add(/node_modules/)
|
||||
.add(entryPath)
|
||||
.end()
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
appPath: getEntryDirPath()
|
||||
})
|
||||
appPath: getEntryDirPath(),
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ import { merge } from 'webpack-merge';
|
||||
import Config from 'webpack-chain';
|
||||
import fs from 'fs';
|
||||
|
||||
import { hasDependency } from "../helpers/dependencies";
|
||||
import { hasDependency } from '../helpers/dependencies';
|
||||
import { getPlatformName } from '../helpers/platform';
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import { error } from "../helpers/log";
|
||||
import { error } from '../helpers/log';
|
||||
import base from './base';
|
||||
|
||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
@@ -15,8 +15,8 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
const platform = getPlatformName();
|
||||
|
||||
// we need to patch VueLoader if we want to enable hmr
|
||||
if(env.hmr) {
|
||||
patchVueLoaderForHMR()
|
||||
if (env.hmr) {
|
||||
patchVueLoaderForHMR();
|
||||
}
|
||||
|
||||
// resolve .vue files
|
||||
@@ -82,12 +82,15 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
*/
|
||||
function patchVueLoaderForHMR() {
|
||||
try {
|
||||
const vueLoaderPath = require.resolve('vue-loader/lib/index.js')
|
||||
const vueLoaderPath = require.resolve('vue-loader/lib/index.js');
|
||||
const source = fs.readFileSync(vueLoaderPath).toString();
|
||||
const patchedSource = source.replace(/(isServer\s=\s)(target\s===\s'node')/g, '$1false;')
|
||||
fs.writeFileSync(vueLoaderPath, patchedSource)
|
||||
delete require.cache[vueLoaderPath]
|
||||
const patchedSource = source.replace(
|
||||
/(isServer\s=\s)(target\s===\s'node')/g,
|
||||
'$1false;'
|
||||
);
|
||||
fs.writeFileSync(vueLoaderPath, patchedSource);
|
||||
delete require.cache[vueLoaderPath];
|
||||
} catch (err) {
|
||||
error('Failed to patch VueLoader - HMR may not work properly!')
|
||||
error('Failed to patch VueLoader - HMR may not work properly!');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user