Martin Dimitrov
Martin Dimitrov

Reputation: 4956

How to ignore folder from being processed by Webpack in NativeScript app

I have a folder inside project-root/app dir that contains HTML/CSS/JS files that will be referenced by WebView control. The problem is Webpack processes this folder and reports many errors. How to ignore it? Thank you.

Here is one of the errors (the bg folder should be ignored by Webpack):

ERROR in ./bg/assets/css/styles.css
Module not found: Error: Can't resolve '@angular/material/prebuilt-themes/deeppurple-amber.css' in '~\app\bg\assets\css'
 @ ./bg/assets/css/styles.css 1:87-152 2:86-151
 @ . sync (?<!\bApp_Resources\b.*)(?<!\.\/\btests\b\/.*?)\.(xml|css|js|kt|(?<!\.d\.)ts|(?<!\b_[\w-]*\.)scss)$
 @ ./app.ts

Upvotes: 0

Views: 701

Answers (1)

Manoj
Manoj

Reputation: 21908

You may adjust webpack config to exclude certain files or folders from the bundle. There are various different ways to do it, I would use ignore plugin

In your webpack.config.js, under plugins array add the following

plugins: [
            new webpack.IgnorePlugin(/bg\/assets\/css/),
            // Define useful constants like TNS_WEBPACK
            new webpack.DefinePlugin({
                "global.TNS_WEBPACK": "true",
                "process": "global.process",
            }),

It will exclude all files from the specific folder.

Upvotes: 1

Related Questions