Skip to content

Commit c7f6bc6

Browse files
committed
webpack configs
1 parent 699e4b1 commit c7f6bc6

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

webpack.common.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const HtmlWebpackPlugin = require("html-webpack-plugin");
2+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
3+
4+
module.exports = {
5+
entry: {
6+
index: "./src/js/index.js",
7+
},
8+
9+
module: {
10+
rules: [
11+
{
12+
test: /\.js$/,
13+
use: "babel-loader",
14+
exclude: /node_modules/,
15+
},
16+
17+
{
18+
test: /\.css$/,
19+
use: [MiniCssExtractPlugin.loader, "css-loader"],
20+
},
21+
{
22+
test: /\.scss$/,
23+
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
24+
},
25+
{
26+
test: /\.html$/,
27+
loader: "html-loader",
28+
},
29+
{
30+
test: /\.(png|jpe?g|gif|svg)$/i,
31+
loader: "file-loader",
32+
options: {
33+
name: "[name].[ext]",
34+
outputPath: "images/",
35+
esModule: false,
36+
},
37+
},
38+
39+
{
40+
test: /\.glsl$/,
41+
use: ["raw-loader", "glslify-loader"],
42+
},
43+
],
44+
},
45+
46+
plugins: [
47+
new HtmlWebpackPlugin({
48+
filename: "index.html",
49+
template: "index.html",
50+
inject: true,
51+
chunks: ["index"],
52+
hash: true,
53+
}),
54+
new MiniCssExtractPlugin({
55+
filename: "styles/[name].css",
56+
chunkFilename: "[id].css",
57+
}),
58+
],
59+
};

webpack.dev.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const path = require("path");
2+
const common = require("./webpack.common");
3+
const { merge } = require("webpack-merge");
4+
5+
module.exports = merge(common, {
6+
mode: "development",
7+
output: {
8+
filename: "scripts/[name].js",
9+
path: path.resolve(__dirname, "dist"),
10+
},
11+
devServer: {
12+
port: 8080,
13+
stats: "errors-only",
14+
},
15+
});

webpack.prod.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const path = require("path");
2+
const common = require("./webpack.common");
3+
const { merge } = require("webpack-merge");
4+
5+
module.exports = merge(common, {
6+
mode: "production",
7+
output: {
8+
filename: "scripts/[name].js",
9+
path: path.resolve(__dirname, "dist"),
10+
},
11+
});

0 commit comments

Comments
 (0)