This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
72 lines (72 loc) · 1.74 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const dotenv = require("dotenv");
const fs = require("fs");
const webpack = require("webpack");
const HtmlWebpackPlugin = require('html-webpack-plugin');
/**
* Load env vars from .env if available
*/
dotenv.config();
module.exports = {
entry: [
path.resolve("src", "js", "index.js"),
path.resolve("src", "js", "theme.js"),
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"],
},
{
test: /\.(png|svg|jpe?g|gif)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
},
},
],
},
{
test: /\.(eot|ttf|woff|woff2)$/,
use: {
loader: "file-loader",
options: {
name: "[name].[ext]",
},
},
},
],
},
resolve: {
extensions: [".jsx", ".scss", ".css", ".js"],
modules: [path.resolve(__dirname, "node_modules")],
},
output: {
path: path.resolve("static", "assets"),
filename: "bundle.js",
},
watchOptions: {
aggregateTimeout: 300,
poll: 1000,
},
plugins: [
new MiniCssExtractPlugin(),
new HtmlWebpackPlugin(),
new webpack.DefinePlugin({
// Provide enviroment variable defaults
// from .env
ALGOLIA_APP_ID: JSON.stringify(process.env.ALGOLIA_APP_ID),
ALGOLIA_INDEX_NAME: JSON.stringify(process.env.ALGOLIA_INDEX_NAME),
ALGOLIA_SEARCH_KEY: JSON.stringify(process.env.ALGOLIA_SEARCH_KEY),
}),
],
};