-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
50 lines (49 loc) · 1.76 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
// Webpack Docs (which are really good): https://webpack.js.org/concepts/
// Webpack configuration for React from scratch: https://medium.com/@JedaiSaboteur/creating-a-react-app-from-scratch-f3c693b84658
module.exports = {
// Specific entry point Webpack should use
entry: './src/index.js',
mode: 'production',
// By default Webpack works on JS & JSON files only, loaders
// specify how to handle other file types.
module: {
rules: [
// Babel loader for transpiling JS/JSX files
// Note .babelrc specifies the babel plugins used
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: { presets: ['@babel/env'] }
},
// CSS loader for transpiling CSS files
// Enables `import "./App.css";` syntax
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
}
],
},
resolve: { extensions: ["*", ".js", ".jsx"] },
plugins: [
// Copies files from `public/` to `dist/`, useful for manifest.json file
// required by Chrome for extensions.
new CopyPlugin({
patterns: [
{ from: "crx/" },
],
}),
// Auto-creates an HTML file (`index.html` by default) which attaches
// the generated JS bundles with <script> tags.
new HtmlWebpackPlugin({
template: 'public/index.html',
}),
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
};