javascript - webpack loaders and include -


i'm new webpack , i'm trying understand loaders properties such test, loader, include etc.

here sample snippet of webpack.config.js found in google.

module: {     loaders: [       {         test: /\.js$/,         loader: 'babel-loader',         include: [           path.resolve(__dirname, 'index.js'),           path.resolve(__dirname, 'config.js'),           path.resolve(__dirname, 'lib'),           path.resolve(__dirname, 'app'),           path.resolve(__dirname, 'src')         ],         exclude: [           path.resolve(__dirname, 'test', 'test.build.js')         ],         cachedirectory: true,         query: {           presets: ['es2015']         }       },     ] } 
  1. am right test: /.js$/ used files extension .js?

  2. the loader: 'babel-loader', loader install using npm

  3. the include: have many questions on this. right put inside array transpiled? means, index.js, config.js, , *.js files in lib, app , src transpiled.

  4. more questions on include: when files transpiled, *.js files concatenated 1 big file?

  5. i think exclude self explanatory. not transpiled.

  6. what query: { presets: ['es2015'] } do?

in webpack config there multiple things configuration, important ones are

  1. entry - can array or object defining entry point asset want bundle, can js test here says /.js$. application if has multiple entry points use array.
  2. include - defines set of path or files imported files transformed loader.
  3. exclude self explanatory (do not transform file these places).
  4. output - final bundle want create. if specify example

    output: { filename: "[name].bundle.js", vendor: "react" }

    then application js files bundled main.bundle.js , react in vendor.js files. error if not use both in html page.

hope helped


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -