|
| 1 | +/** |
| 2 | + * Webpack config for production electron main process |
| 3 | + */ |
| 4 | + |
| 5 | +import webpack from 'webpack'; |
| 6 | +import path from 'path'; |
| 7 | +import BabiliPlugin from 'babili-webpack-plugin'; |
| 8 | + |
| 9 | +const projectDir = path.resolve(__dirname, '../'); |
| 10 | + |
| 11 | + |
| 12 | +export default { |
| 13 | + target: 'electron-main', |
| 14 | + |
| 15 | + entry: 'main.dev', |
| 16 | + |
| 17 | + module: { |
| 18 | + rules: [{ |
| 19 | + test: /\.jsx?$/, |
| 20 | + exclude: /node_modules/, |
| 21 | + use: { |
| 22 | + loader: 'babel-loader', |
| 23 | + options: { |
| 24 | + cacheDirectory: true |
| 25 | + } |
| 26 | + } |
| 27 | + }] |
| 28 | + }, |
| 29 | + |
| 30 | + output: { |
| 31 | + path: path.join(projectDir, 'app'), |
| 32 | + filename: 'main.prod.js' |
| 33 | + }, |
| 34 | + |
| 35 | + resolve: { |
| 36 | + extensions: ['.js', '.jsx', '.json'], |
| 37 | + modules: [ |
| 38 | + path.join(projectDir, 'app'), |
| 39 | + 'node_modules', |
| 40 | + ], |
| 41 | + }, |
| 42 | + |
| 43 | + plugins: [ |
| 44 | + /** |
| 45 | + * Babli is an ES6+ aware minifier based on the Babel toolchain (beta) |
| 46 | + */ |
| 47 | + new BabiliPlugin(), |
| 48 | + |
| 49 | + /** |
| 50 | + * Create global constants which can be configured at compile time. |
| 51 | + * |
| 52 | + * Useful for allowing different behaviour between development builds and |
| 53 | + * release builds |
| 54 | + * |
| 55 | + * NODE_ENV should be production so that modules do not perform certain |
| 56 | + * development checks |
| 57 | + */ |
| 58 | + new webpack.DefinePlugin({ |
| 59 | + 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'), |
| 60 | + 'process.env.DEBUG_PROD': JSON.stringify(process.env.DEBUG_PROD || 'false') |
| 61 | + }) |
| 62 | + ], |
| 63 | + |
| 64 | + /** |
| 65 | + * Disables webpack processing of __dirname and __filename. |
| 66 | + * If you run the bundle in node.js it falls back to these values of node.js. |
| 67 | + * https://github.com/webpack/webpack/issues/2010 |
| 68 | + */ |
| 69 | + node: { |
| 70 | + __dirname: false, |
| 71 | + __filename: false |
| 72 | + }, |
| 73 | +}; |
0 commit comments