|
1 | 1 | 'use strict'
|
2 | 2 |
|
3 | 3 | const path = require('path')
|
4 |
| -const TerserPlugin = require('terser-webpack-plugin') |
| 4 | +const webpack = require('webpack') |
| 5 | +const NodePolyfillPlugin = require('node-polyfill-webpack-plugin') |
5 | 6 | const HtmlWebpackPlugin = require('html-webpack-plugin')
|
6 | 7 |
|
7 | 8 | module.exports = {
|
8 |
| - mode: 'development', |
9 |
| - devtool: 'source-map', |
| 9 | + devtool: 'eval', |
10 | 10 | entry: [
|
11 | 11 | './index.js'
|
12 | 12 | ],
|
| 13 | + output: { |
| 14 | + path: path.join(__dirname, 'dist'), |
| 15 | + filename: 'bundle.js' |
| 16 | + }, |
13 | 17 | plugins: [
|
14 | 18 | new HtmlWebpackPlugin({
|
15 | 19 | title: 'IPFS MFS example',
|
16 | 20 | template: 'index.html'
|
| 21 | + }), |
| 22 | + // fixes Module not found: Error: Can't resolve 'stream' in '.../node_modules/nofilter/lib' |
| 23 | + new NodePolyfillPlugin(), |
| 24 | + // Note: stream-browserify has assumption about `Buffer` global in its |
| 25 | + // dependencies causing runtime errors. This is a workaround to provide |
| 26 | + // global `Buffer` until https://github.com/isaacs/core-util-is/issues/29 |
| 27 | + // is fixed. |
| 28 | + new webpack.ProvidePlugin({ |
| 29 | + Buffer: ['buffer', 'Buffer'], |
| 30 | + process: 'process/browser' |
17 | 31 | })
|
18 |
| - ], |
19 |
| - optimization: { |
20 |
| - minimizer: [ |
21 |
| - new TerserPlugin({ |
22 |
| - terserOptions: { |
23 |
| - parse: { |
24 |
| - // we want terser to parse ecma 8 code. However, we don't want it |
25 |
| - // to apply any minfication steps that turns valid ecma 5 code |
26 |
| - // into invalid ecma 5 code. This is why the 'compress' and 'output' |
27 |
| - // sections only apply transformations that are ecma 5 safe |
28 |
| - // https://github.com/facebook/create-react-app/pull/4234 |
29 |
| - ecma: 8 |
30 |
| - }, |
31 |
| - compress: { |
32 |
| - ecma: 5, |
33 |
| - warnings: false |
34 |
| - }, |
35 |
| - mangle: { |
36 |
| - safari10: true |
37 |
| - }, |
38 |
| - output: { |
39 |
| - ecma: 5, |
40 |
| - comments: false |
41 |
| - } |
42 |
| - }, |
43 |
| - // Use multi-process parallel running to improve the build speed |
44 |
| - // Default number of concurrent runs: os.cpus().length - 1 |
45 |
| - parallel: true, |
46 |
| - // Enable file caching |
47 |
| - cache: true, |
48 |
| - sourceMap: true |
49 |
| - }) |
50 |
| - ] |
51 |
| - }, |
52 |
| - output: { |
53 |
| - path: path.join(__dirname, 'dist'), |
54 |
| - filename: 'bundle.js' |
55 |
| - }, |
56 |
| - node: { |
57 |
| - fs: 'empty' |
58 |
| - } |
| 32 | + ] |
59 | 33 | }
|
0 commit comments