8

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

newnewnews
  • 123
  • 1
  • 5
  • Can you elaborate more with, for example, an example on what you mean with "specific plugin or loader for certain file/folders"? Note that in order to get great answers, you should look into [how to write good questions](http://stackoverflow.com/help/how-to-ask). – Juliën Feb 18 '17 at 12:34

1 Answers1

12

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

José Quinto Zamora
  • 2,070
  • 12
  • 15
  • I have another problem. i have tried to use https://github.com/petehunt/we... async-loading with require-ensure , as replacement for my < script src='path to js'> . But now build fails with 'ERROR in ./~/file-loader?emitFile=false!./path/to/myfile.js Module build failed: SyntaxError: Deleting local variable in strict mode' . but i have not 'use strict' in this .js file. I have searched for some 'disable use strict' plugins , but still unsuccessful – newnewnews Feb 18 '17 at 12:35
  • i have angular template and – newnewnews Feb 18 '17 at 12:37
  • 8
    This is an answer for loaders, but how about plugins? – trysis Feb 26 '19 at 17:28