Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how tell to webpack to use plugin or loader only for specific file?

I want to force the webpack to enable specific plugin or loader for certain file/folder, multiply files. Is there a way?

like image 409
newnewnews Avatar asked Feb 18 '17 08:02

newnewnews


1 Answers

You can use "include" to only include a specific folder for this rule. For example (this code only compile .ts files in /app/src folder)

        {
            test: /\.ts$/,
            use: [
                { loader: 'react-hot-loader/webpack' },
                { loader: 'awesome-typescript-loader' }
            ],
            include: resolve(__dirname, './../app/src')
        },

More examples here: https://webpack.js.org/configuration/module/#condition

like image 124
José Quinto Zamora Avatar answered Sep 29 '22 23:09

José Quinto Zamora