mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-20 07:26:11 +08:00
chore: more base configuration
This commit is contained in:
@ -3,6 +3,18 @@
|
||||
exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR enabled 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/android/app/src/main/assets/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
@ -12,7 +24,17 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
'.tsx'
|
||||
'.tsx',
|
||||
'.android.ts',
|
||||
'.ts',
|
||||
'.android.js',
|
||||
'.js',
|
||||
'.android.css',
|
||||
'.css',
|
||||
'.android.scss',
|
||||
'.scss',
|
||||
'.android.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
@ -96,6 +118,22 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: false,
|
||||
sequences: false
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
@ -113,17 +151,12 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
|
||||
'global.isAndroid': true,
|
||||
'global.isIOS': false,
|
||||
process: 'global.process',
|
||||
profile: '() => {}',
|
||||
__DEV__: 'true',
|
||||
__TEST__: 'false',
|
||||
'process.env.NODE_ENV': '\\"development\\"'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPluginTemp(
|
||||
{
|
||||
patterns: []
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStateLoggerPlugin') */
|
||||
new WatchStateLoggerPlugin(),
|
||||
/* config.plugin('ReactRefreshWebpackPlugin') */
|
||||
@ -136,7 +169,7 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
|
||||
],
|
||||
entry: {
|
||||
bundle: [
|
||||
'todo/main'
|
||||
'src/app.js'
|
||||
]
|
||||
}
|
||||
}"
|
||||
@ -145,6 +178,18 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
|
||||
exports[`react configuration > android > base config 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/android/app/src/main/assets/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
@ -154,7 +199,17 @@ exports[`react configuration > android > base config 1`] = `
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
'.tsx'
|
||||
'.tsx',
|
||||
'.android.ts',
|
||||
'.ts',
|
||||
'.android.js',
|
||||
'.js',
|
||||
'.android.css',
|
||||
'.css',
|
||||
'.android.scss',
|
||||
'.scss',
|
||||
'.android.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
@ -238,6 +293,22 @@ exports[`react configuration > android > base config 1`] = `
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: false,
|
||||
sequences: false
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
@ -255,23 +326,18 @@ exports[`react configuration > android > base config 1`] = `
|
||||
'global.isAndroid': true,
|
||||
'global.isIOS': false,
|
||||
process: 'global.process',
|
||||
profile: '() => {}',
|
||||
__DEV__: 'true',
|
||||
__TEST__: 'false',
|
||||
'process.env.NODE_ENV': '\\"development\\"'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPluginTemp(
|
||||
{
|
||||
patterns: []
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStateLoggerPlugin') */
|
||||
new WatchStateLoggerPlugin()
|
||||
],
|
||||
entry: {
|
||||
bundle: [
|
||||
'todo/main'
|
||||
'src/app.js'
|
||||
]
|
||||
}
|
||||
}"
|
||||
@ -280,6 +346,18 @@ exports[`react configuration > android > base config 1`] = `
|
||||
exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR enabled 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/ios/__jest__/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
@ -289,7 +367,17 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
'.tsx'
|
||||
'.tsx',
|
||||
'.ios.ts',
|
||||
'.ts',
|
||||
'.ios.js',
|
||||
'.js',
|
||||
'.ios.css',
|
||||
'.css',
|
||||
'.ios.scss',
|
||||
'.scss',
|
||||
'.ios.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
@ -373,12 +461,28 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: true,
|
||||
sequences: true
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
{
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
'platforms/ios/[todo]/app/**/*'
|
||||
'platforms/ios/__jest__/app/**/*'
|
||||
],
|
||||
verbose: true
|
||||
}
|
||||
@ -390,17 +494,12 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
|
||||
'global.isAndroid': false,
|
||||
'global.isIOS': true,
|
||||
process: 'global.process',
|
||||
profile: '() => {}',
|
||||
__DEV__: 'true',
|
||||
__TEST__: 'false',
|
||||
'process.env.NODE_ENV': '\\"development\\"'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPluginTemp(
|
||||
{
|
||||
patterns: []
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStateLoggerPlugin') */
|
||||
new WatchStateLoggerPlugin(),
|
||||
/* config.plugin('ReactRefreshWebpackPlugin') */
|
||||
@ -412,11 +511,11 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
|
||||
)
|
||||
],
|
||||
entry: {
|
||||
inspector_modules: [
|
||||
'tns_modules/@nativescript/core/inspector_modules'
|
||||
],
|
||||
bundle: [
|
||||
'todo/main'
|
||||
'src/app.js'
|
||||
],
|
||||
'tns_modules/@nativescript/core/inspector_modules': [
|
||||
'@nativescript/core/inspector_modules'
|
||||
]
|
||||
}
|
||||
}"
|
||||
@ -425,6 +524,18 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
|
||||
exports[`react configuration > ios > base config 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/ios/__jest__/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
@ -434,7 +545,17 @@ exports[`react configuration > ios > base config 1`] = `
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
'.tsx'
|
||||
'.tsx',
|
||||
'.ios.ts',
|
||||
'.ts',
|
||||
'.ios.js',
|
||||
'.js',
|
||||
'.ios.css',
|
||||
'.css',
|
||||
'.ios.scss',
|
||||
'.scss',
|
||||
'.ios.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
@ -518,12 +639,28 @@ exports[`react configuration > ios > base config 1`] = `
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: true,
|
||||
sequences: true
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
{
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
'platforms/ios/[todo]/app/**/*'
|
||||
'platforms/ios/__jest__/app/**/*'
|
||||
],
|
||||
verbose: true
|
||||
}
|
||||
@ -535,26 +672,21 @@ exports[`react configuration > ios > base config 1`] = `
|
||||
'global.isAndroid': false,
|
||||
'global.isIOS': true,
|
||||
process: 'global.process',
|
||||
profile: '() => {}',
|
||||
__DEV__: 'true',
|
||||
__TEST__: 'false',
|
||||
'process.env.NODE_ENV': '\\"development\\"'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPluginTemp(
|
||||
{
|
||||
patterns: []
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStateLoggerPlugin') */
|
||||
new WatchStateLoggerPlugin()
|
||||
],
|
||||
entry: {
|
||||
inspector_modules: [
|
||||
'tns_modules/@nativescript/core/inspector_modules'
|
||||
],
|
||||
bundle: [
|
||||
'todo/main'
|
||||
'src/app.js'
|
||||
],
|
||||
'tns_modules/@nativescript/core/inspector_modules': [
|
||||
'@nativescript/core/inspector_modules'
|
||||
]
|
||||
}
|
||||
}"
|
||||
|
||||
@ -3,6 +3,18 @@
|
||||
exports[`vue configuration for android 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/android/app/src/main/assets/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
@ -12,7 +24,17 @@ exports[`vue configuration for android 1`] = `
|
||||
vue: 'nativescript-vue'
|
||||
},
|
||||
extensions: [
|
||||
'.vue'
|
||||
'.vue',
|
||||
'.android.ts',
|
||||
'.ts',
|
||||
'.android.js',
|
||||
'.js',
|
||||
'.android.css',
|
||||
'.css',
|
||||
'.android.scss',
|
||||
'.scss',
|
||||
'.android.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
@ -100,7 +122,25 @@ exports[`vue configuration for android 1`] = `
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: false,
|
||||
sequences: false
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('VueLoaderPlugin') */
|
||||
new VueLoaderPlugin(),
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
{
|
||||
@ -116,23 +156,16 @@ exports[`vue configuration for android 1`] = `
|
||||
'global.NS_WEBPACK': true,
|
||||
'global.isAndroid': true,
|
||||
'global.isIOS': false,
|
||||
process: 'global.process'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPluginTemp(
|
||||
{
|
||||
patterns: []
|
||||
process: 'global.process',
|
||||
profile: '() => {}'
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStateLoggerPlugin') */
|
||||
new WatchStateLoggerPlugin(),
|
||||
/* config.plugin('VueLoaderPlugin') */
|
||||
new VueLoaderPlugin()
|
||||
new WatchStateLoggerPlugin()
|
||||
],
|
||||
entry: {
|
||||
bundle: [
|
||||
'todo/main'
|
||||
'src/app.js'
|
||||
]
|
||||
}
|
||||
}"
|
||||
@ -141,6 +174,18 @@ exports[`vue configuration for android 1`] = `
|
||||
exports[`vue configuration for ios 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/ios/__jest__/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
@ -150,7 +195,17 @@ exports[`vue configuration for ios 1`] = `
|
||||
vue: 'nativescript-vue'
|
||||
},
|
||||
extensions: [
|
||||
'.vue'
|
||||
'.vue',
|
||||
'.ios.ts',
|
||||
'.ts',
|
||||
'.ios.js',
|
||||
'.js',
|
||||
'.ios.css',
|
||||
'.css',
|
||||
'.ios.scss',
|
||||
'.scss',
|
||||
'.ios.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
@ -238,12 +293,30 @@ exports[`vue configuration for ios 1`] = `
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: true,
|
||||
sequences: true
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('VueLoaderPlugin') */
|
||||
new VueLoaderPlugin(),
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
{
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
'platforms/ios/[todo]/app/**/*'
|
||||
'platforms/ios/__jest__/app/**/*'
|
||||
],
|
||||
verbose: true
|
||||
}
|
||||
@ -254,26 +327,19 @@ exports[`vue configuration for ios 1`] = `
|
||||
'global.NS_WEBPACK': true,
|
||||
'global.isAndroid': false,
|
||||
'global.isIOS': true,
|
||||
process: 'global.process'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPluginTemp(
|
||||
{
|
||||
patterns: []
|
||||
process: 'global.process',
|
||||
profile: '() => {}'
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStateLoggerPlugin') */
|
||||
new WatchStateLoggerPlugin(),
|
||||
/* config.plugin('VueLoaderPlugin') */
|
||||
new VueLoaderPlugin()
|
||||
new WatchStateLoggerPlugin()
|
||||
],
|
||||
entry: {
|
||||
inspector_modules: [
|
||||
'tns_modules/@nativescript/core/inspector_modules'
|
||||
],
|
||||
bundle: [
|
||||
'todo/main'
|
||||
'src/app.js'
|
||||
],
|
||||
'tns_modules/@nativescript/core/inspector_modules': [
|
||||
'@nativescript/core/inspector_modules'
|
||||
]
|
||||
}
|
||||
}"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// @ts-ignore
|
||||
import Config from 'webpack-chain';
|
||||
import react from '../../src/configuration/react';
|
||||
import { init } from '../../src';
|
||||
|
||||
describe('react configuration', () => {
|
||||
const platforms = ['ios', 'android'];
|
||||
@ -8,20 +9,18 @@ describe('react configuration', () => {
|
||||
for (let platform of platforms) {
|
||||
describe(`> ${platform} >`, () => {
|
||||
it(`base config`, () => {
|
||||
expect(
|
||||
react(new Config(), {
|
||||
[platform]: true,
|
||||
}).toString()
|
||||
).toMatchSnapshot();
|
||||
init({
|
||||
[platform]: true,
|
||||
});
|
||||
expect(react(new Config()).toString()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it(`adds ReactRefreshWebpackPlugin when HMR enabled`, () => {
|
||||
expect(
|
||||
react(new Config(), {
|
||||
[platform]: true,
|
||||
hmr: true,
|
||||
}).toString()
|
||||
).toMatchSnapshot();
|
||||
init({
|
||||
[platform]: true,
|
||||
hmr: true,
|
||||
});
|
||||
expect(react(new Config()).toString()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
// @ts-ignore
|
||||
import Config from 'webpack-chain';
|
||||
import vue from '../../src/configuration/vue';
|
||||
import { init } from '../../src';
|
||||
|
||||
describe.only('vue configuration', () => {
|
||||
const platforms = ['ios', 'android'];
|
||||
|
||||
for (let platform of platforms) {
|
||||
it(`for ${platform}`, () => {
|
||||
expect(
|
||||
vue(new Config(), {
|
||||
[platform]: true,
|
||||
}).toString()
|
||||
).toMatchSnapshot();
|
||||
init({
|
||||
[platform]: true,
|
||||
});
|
||||
expect(vue(new Config()).toString()).toMatchSnapshot();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -13,6 +13,7 @@ describe('@nativescript/webpack', () => {
|
||||
});
|
||||
|
||||
it('applies chain configs', () => {
|
||||
webpack.useConfig(false);
|
||||
expect(webpack.chainWebpack).toBeInstanceOf(Function);
|
||||
|
||||
const chainFn = jest.fn();
|
||||
|
||||
Reference in New Issue
Block a user