1 var path = require("path");
2 var webpack = require("webpack");
3 var UglifyJsPlugin = require("uglifyjs-webpack-plugin");
6 entryPoint: path.resolve(__dirname, './src/index.ts'),
7 bundles: path.resolve(__dirname, 'dist'),
11 // These are the entry point of our library. We tell webpack to use
12 // the name we assign later, when creating the bundle. We also use
13 // the name to filter the second entry point for applying code
14 // minification via UglifyJS
16 'sdc-pubsub': PATHS.entryPoint,
17 'sdc-pubsub.min': PATHS.entryPoint
19 // The output defines how and where we want the bundles. The special
20 // value `[name]` in `filename` tell Webpack to use the name we defined above.
21 // We target a UMD and name it MyLib. When including the bundle in the browser
22 // it will be accessible at `window.MyLib`
25 filename: '[name].js',
30 // Add resolve for `tsx` and `ts` files, otherwise Webpack would
31 // only look for common JavaScript file extension (.js)
33 extensions: ['.ts', '.js']
35 // Activate source maps for the bundles in order to preserve the original
36 // source when the user debugs the application
37 devtool: 'source-map',
39 // Apply minification only on the second bundle by
40 // using a RegEx on the name, which must end with `.min.js`
41 // NB: Remember to activate sourceMaps in UglifyJsPlugin
42 // since they are disabled by default!
45 include: /\.min\.js$/,
49 // Webpack doesn't understand TypeScript files and a loader is needed.
50 // `node_modules` folder is excluded in order to prevent problems with
51 // the library dependencies, as well as `__tests__` folders that
52 // contain the tests for the library
60 configFile: 'tsconfig.json'
68 module.exports = config;