|
| 1 | +const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); |
| 2 | +const path = require('path'); |
| 3 | +const nodeExternals = require('webpack-node-externals'); |
| 4 | + |
| 5 | +console.log(require.resolve('babel-loader')); |
| 6 | + |
| 7 | +module.exports = { |
| 8 | + entry: { |
| 9 | + // We take care of setting up the server under ./server.js |
| 10 | + index: ['graphpack'], |
| 11 | + }, |
| 12 | + // When bundling with Webpack for the backend you usually don't want to bundle |
| 13 | + // its node_modules dependencies. This creates an externals function that |
| 14 | + // ignores node_modules when bundling in Webpack. |
| 15 | + externals: [nodeExternals({ whitelist: [/^graphpack$/] })], |
| 16 | + mode: 'development', |
| 17 | + module: { |
| 18 | + rules: [ |
| 19 | + { |
| 20 | + test: /\.graphql/, |
| 21 | + use: 'graphql-tag/loader', |
| 22 | + }, |
| 23 | + { |
| 24 | + test: /\.js$/, |
| 25 | + use: [ |
| 26 | + { |
| 27 | + loader: require.resolve('babel-loader'), |
| 28 | + options: { |
| 29 | + babelrc: true, |
| 30 | + cacheDirectory: true, |
| 31 | + presets: [require.resolve('../babel')], |
| 32 | + }, |
| 33 | + }, |
| 34 | + ], |
| 35 | + }, |
| 36 | + { |
| 37 | + test: /\.mjs$/, |
| 38 | + type: 'javascript/auto', |
| 39 | + }, |
| 40 | + ], |
| 41 | + }, |
| 42 | + optimization: { noEmitOnErrors: true }, |
| 43 | + output: { |
| 44 | + filename: '[name].js', |
| 45 | + libraryTarget: 'commonjs2', |
| 46 | + path: path.join(process.cwd(), './build'), |
| 47 | + sourceMapFilename: '[name].map', |
| 48 | + }, |
| 49 | + plugins: [new FriendlyErrorsWebpackPlugin({ clearConsole: false })], |
| 50 | + resolve: { |
| 51 | + alias: { __GRAPHPACK_SRC__: path.resolve(process.cwd(), 'src') }, |
| 52 | + extensions: ['.wasm', '.js', '.mjs', '.json', '.graphql'], |
| 53 | + }, |
| 54 | + stats: 'minimal', |
| 55 | + target: 'node', |
| 56 | +}; |
0 commit comments