mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 13:22:19 +08:00
chore: add comments
This commit is contained in:

committed by
Nathan Walker

parent
1e2c8e9932
commit
7e8c6a900a
6
packages/webpack5/.prettierrc.json
Normal file
6
packages/webpack5/.prettierrc.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"useTabs": true,
|
||||||
|
"printWidth": 80,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"singleQuote": true
|
||||||
|
}
|
@ -1,6 +1,11 @@
|
|||||||
import Config from 'webpack-chain';
|
import Config from 'webpack-chain';
|
||||||
import { IWebpackEnv, Platform } from '../index';
|
import { IWebpackEnv, Platform } from '../index';
|
||||||
import { getAbsoluteDistPath, getDistPath, getEntryPath, getPackageJson } from '../helpers/project';
|
import {
|
||||||
|
getAbsoluteDistPath,
|
||||||
|
getDistPath,
|
||||||
|
getEntryPath,
|
||||||
|
getPackageJson,
|
||||||
|
} from '../helpers/project';
|
||||||
|
|
||||||
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
||||||
import { DefinePlugin } from 'webpack';
|
import { DefinePlugin } from 'webpack';
|
||||||
@ -22,11 +27,18 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
|||||||
// todo: devtool
|
// todo: devtool
|
||||||
config.devtool('inline-source-map');
|
config.devtool('inline-source-map');
|
||||||
|
|
||||||
|
// todo: figure out easiest way to make "node" target work in ns,
|
||||||
|
// rather than the custom ns target implementation that's hard to maintain
|
||||||
config.target('node');
|
config.target('node');
|
||||||
|
|
||||||
config.entry('bundle').add(entryPath);
|
config.entry('bundle').add(entryPath);
|
||||||
|
|
||||||
config.output.path(getAbsoluteDistPath()).pathinfo(false).publicPath('').libraryTarget('commonjs').globalObject('global');
|
config.output
|
||||||
|
.path(getAbsoluteDistPath())
|
||||||
|
.pathinfo(false)
|
||||||
|
.publicPath('')
|
||||||
|
.libraryTarget('commonjs')
|
||||||
|
.globalObject('global');
|
||||||
|
|
||||||
// Set up Terser options
|
// Set up Terser options
|
||||||
config.optimization.minimizer('TerserPlugin').use(TerserPlugin, [
|
config.optimization.minimizer('TerserPlugin').use(TerserPlugin, [
|
||||||
@ -45,17 +57,34 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
|||||||
// look for loaders in
|
// look for loaders in
|
||||||
// - @nativescript/webpack/loaders
|
// - @nativescript/webpack/loaders
|
||||||
// - node_modules
|
// - node_modules
|
||||||
config.resolveLoader.modules.add('@nativescript/webpack/dist/loaders').add('node_modules');
|
config.resolveLoader.modules
|
||||||
|
.add('@nativescript/webpack/dist/loaders')
|
||||||
|
.add('node_modules');
|
||||||
|
|
||||||
// inspector_modules
|
// inspector_modules
|
||||||
config.when(shouldIncludeInspectorModules(env), (config) => {
|
config.when(shouldIncludeInspectorModules(env), (config) => {
|
||||||
config.entry('tns_modules/@nativescript/core/inspector_modules').add('@nativescript/core/inspector_modules');
|
config
|
||||||
|
.entry('tns_modules/@nativescript/core/inspector_modules')
|
||||||
|
.add('@nativescript/core/inspector_modules');
|
||||||
});
|
});
|
||||||
|
|
||||||
config.resolve.extensions.add(`.${platform}.ts`).add('.ts').add(`.${platform}.js`).add('.js').add(`.${platform}.css`).add('.css').add(`.${platform}.scss`).add('.scss').add(`.${platform}.json`).add('.json');
|
config.resolve.extensions
|
||||||
|
.add(`.${platform}.ts`)
|
||||||
|
.add('.ts')
|
||||||
|
.add(`.${platform}.js`)
|
||||||
|
.add('.js')
|
||||||
|
.add(`.${platform}.css`)
|
||||||
|
.add('.css')
|
||||||
|
.add(`.${platform}.scss`)
|
||||||
|
.add('.scss')
|
||||||
|
.add(`.${platform}.json`)
|
||||||
|
.add('.json');
|
||||||
|
|
||||||
// base aliases
|
// base aliases
|
||||||
config.resolve.alias.set('~/package.json', 'package.json').set('~', '<TODO>appFullPath').set('@', '<TODO>appFullPath');
|
config.resolve.alias
|
||||||
|
.set('~/package.json', 'package.json')
|
||||||
|
.set('~', '<TODO>appFullPath')
|
||||||
|
.set('@', '<TODO>appFullPath');
|
||||||
|
|
||||||
// resolve symlinks
|
// resolve symlinks
|
||||||
config.resolve.symlinks(true);
|
config.resolve.symlinks(true);
|
||||||
@ -85,7 +114,11 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
|||||||
|
|
||||||
// set up js
|
// set up js
|
||||||
// todo: do we need babel-loader? It's useful to support it
|
// todo: do we need babel-loader? It's useful to support it
|
||||||
config.module.rule('js').test(/\.js$/).use('babel-loader').loader('babel-loader');
|
config.module
|
||||||
|
.rule('js')
|
||||||
|
.test(/\.js$/)
|
||||||
|
.use('babel-loader')
|
||||||
|
.loader('babel-loader');
|
||||||
|
|
||||||
// set up css
|
// set up css
|
||||||
config.module
|
config.module
|
||||||
|
Reference in New Issue
Block a user