|
| 1 | +// webpack.config.js |
| 2 | +const path = require("path"); |
| 3 | + |
| 4 | +// We'll refer to our source and dist paths frequently, so let's store them here |
| 5 | +const PATH_SOURCE = path.join(__dirname, "./src"); |
| 6 | +const PATH_DIST = path.join(__dirname, "./dist"); |
| 7 | + |
| 8 | +// Export a configuration object |
| 9 | +module.exports = { |
| 10 | + // Tell Webpack to do some optimizations for our environment (development |
| 11 | + // or production). Webpack will enable certain plugins and set |
| 12 | + // `process.env.NODE_ENV` according to the environment we specify. |
| 13 | + // https://webpack.js.org/configuration/mode |
| 14 | + mode: "development", |
| 15 | + |
| 16 | + // The point or points to enter the application. This is where Webpack will |
| 17 | + // start. We generally have one entry point per HTML page. For single-page |
| 18 | + // applications, this means one entry point. For traditional multi-page apps, |
| 19 | + // we may have multiple entry points. |
| 20 | + // https://webpack.js.org/concepts#entry |
| 21 | + entry: [path.join(PATH_SOURCE, "./index.js")], |
| 22 | + |
| 23 | + // Tell Webpack where to emit the bundles it creates and how to name them. |
| 24 | + // https://webpack.js.org/concepts#output |
| 25 | + // https://webpack.js.org/configuration/output |
| 26 | + // https://webpack.js.org/configuration/output#outputFilename |
| 27 | + output: { |
| 28 | + path: PATH_DIST, |
| 29 | + filename: "js/[name].[contenthash].js", |
| 30 | + |
| 31 | + // The public URL of the output dir when referenced in a browser. |
| 32 | + // This value is prefixed to every URL created by the runtime or loaders. |
| 33 | + // It's empty by default, which creates URLs like 'bundle.js' and results |
| 34 | + // in 404s if they're requested from a nested URL like /articles/1 |
| 35 | + // https://webpack.js.org/configuration/output/#outputpublicpath |
| 36 | + publicPath: "/", |
| 37 | + }, |
| 38 | +}; |
0 commit comments