mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: app-css-loader & suppress env warning in ng projects
This commit is contained in:
@@ -17,7 +17,8 @@ exports[`angular configuration for android 1`] = `
|
||||
},
|
||||
ignoreWarnings: [
|
||||
/System.import\\\\(\\\\) is deprecated/,
|
||||
/Zone\\\\.js does not support native async\\\\/await/
|
||||
/Zone\\\\.js does not support native async\\\\/await/,
|
||||
/environment.(\\\\w+).ts is part of the TypeScript compilation but it's unused/
|
||||
],
|
||||
output: {
|
||||
path: '__jest__/platforms/android/app/src/main/assets/app',
|
||||
@@ -63,6 +64,10 @@ exports[`angular configuration for android 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -309,7 +314,8 @@ exports[`angular configuration for ios 1`] = `
|
||||
},
|
||||
ignoreWarnings: [
|
||||
/System.import\\\\(\\\\) is deprecated/,
|
||||
/Zone\\\\.js does not support native async\\\\/await/
|
||||
/Zone\\\\.js does not support native async\\\\/await/,
|
||||
/environment.(\\\\w+).ts is part of the TypeScript compilation but it's unused/
|
||||
],
|
||||
output: {
|
||||
path: '__jest__/platforms/ios/jest/app',
|
||||
@@ -355,6 +361,10 @@ exports[`angular configuration for ios 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
|
||||
@@ -58,6 +58,10 @@ exports[`base configuration for android 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -337,6 +341,10 @@ exports[`base configuration for ios 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
|
||||
@@ -58,6 +58,10 @@ exports[`javascript configuration for android 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -375,6 +379,10 @@ exports[`javascript configuration for ios 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
|
||||
@@ -61,6 +61,10 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -368,6 +372,10 @@ exports[`react configuration > android > base config 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -653,6 +661,10 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -961,6 +973,10 @@ exports[`react configuration > ios > base config 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
|
||||
@@ -60,6 +60,10 @@ exports[`svelte configuration for android 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -364,6 +368,10 @@ exports[`svelte configuration for ios 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
|
||||
@@ -58,6 +58,10 @@ exports[`typescript configuration for android 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -375,6 +379,10 @@ exports[`typescript configuration for ios 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
|
||||
@@ -61,6 +61,10 @@ exports[`vue configuration for android 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
@@ -372,6 +376,10 @@ exports[`vue configuration for ios 1`] = `
|
||||
enforce: 'post',
|
||||
test: '__jest__/src/app.js',
|
||||
use: [
|
||||
/* config.module.rule('bundle').use('app-css-loader') */
|
||||
{
|
||||
loader: 'app-css-loader'
|
||||
},
|
||||
/* config.module.rule('bundle').use('nativescript-hot-loader') */
|
||||
{
|
||||
loader: 'nativescript-hot-loader',
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
"webpack": "^5.28.0",
|
||||
"webpack-bundle-analyzer": "^4.4.0",
|
||||
"webpack-chain": "^6.5.1",
|
||||
"webpack-cli": "^4.6.0",
|
||||
"webpack-merge": "^5.4.0",
|
||||
"webpack-virtual-modules": "^0.4.2",
|
||||
"worker-plugin": "^5.0.0"
|
||||
|
||||
@@ -63,6 +63,14 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
* +-----------------------------------------------------------------------------------------+
|
||||
*/
|
||||
/Zone\.js does not support native async\/await/,
|
||||
/**
|
||||
* This rule hides
|
||||
* +-----------------------------------------------------------------------------------------+
|
||||
* | WARNING in environment.*.ts is part of the TypeScript compilation but it's unused. |
|
||||
* | Add only entry points to the 'files' or 'include' properties in your tsconfig. |
|
||||
* +-----------------------------------------------------------------------------------------+
|
||||
*/
|
||||
/environment.(\w+).ts is part of the TypeScript compilation but it's unused/,
|
||||
])
|
||||
);
|
||||
|
||||
|
||||
@@ -140,6 +140,9 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
.rule('bundle')
|
||||
.enforce('post')
|
||||
.test(entryPath)
|
||||
.use('app-css-loader')
|
||||
.loader('app-css-loader')
|
||||
.end()
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
|
||||
25
packages/webpack5/src/loaders/app-css-loader/index.ts
Normal file
25
packages/webpack5/src/loaders/app-css-loader/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { dedent } from 'ts-dedent';
|
||||
|
||||
/**
|
||||
* This loader tries to load an `app.scss` or and `app.css` relative to the main entry
|
||||
*/
|
||||
export default function loader(content: string, map: any) {
|
||||
const callback = this.async();
|
||||
const resolve = this.getResolve({
|
||||
extensions: ['.scss', '.css'],
|
||||
});
|
||||
|
||||
resolve(this.context, './app', (err, res) => {
|
||||
if (err || !res) {
|
||||
return callback(null, content, map);
|
||||
}
|
||||
|
||||
const code = dedent`
|
||||
// Added by app-css-loader
|
||||
import "${res}";
|
||||
${content}
|
||||
`;
|
||||
|
||||
callback(null, code, map);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user