game-of-life/webpack.common.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-05-23 06:31:43 +00:00
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { DefinePlugin } = require("webpack");
2020-05-23 06:31:43 +00:00
module.exports = {
entry: {
app: "./src/index.js",
},
plugins: [
// new CleanWebpackPlugin(['dist/*']) for < v2 versions of CleanWebpackPlugin
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
2020-05-23 20:03:51 +00:00
template: "index.html",
2020-05-23 06:31:43 +00:00
}),
new DefinePlugin({
2020-05-26 06:54:38 +00:00
"process.env.API_TOKEN": JSON.stringify(process.env.API_TOKEN),
}),
2020-05-23 06:31:43 +00:00
],
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "dist"),
2020-05-23 20:03:51 +00:00
chunkFilename: "[name].bundle.js",
2020-05-23 06:31:43 +00:00
},
2020-05-23 20:03:51 +00:00
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
2020-05-23 06:31:43 +00:00
},
2020-05-23 20:03:51 +00:00
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.html$/i,
loader: "html-loader",
options: {
attributes: true,
},
},
],
},
2020-05-23 06:31:43 +00:00
};