-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
83 lines (79 loc) · 2.03 KB
/
webpack.common.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
73
74
75
76
77
78
79
80
81
82
83
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const BrowserSyncPlugin = require("browser-sync-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
var path = require("path");
// change these variables to fit your project
const jsPath = "./src";
const cssPath = "./src";
const outputPath = "dist";
const localDomain = "index.html";
const entryPoints = {
// 'app' is the output name, people commonly use 'bundle'
// you can have more than 1 entry point
PageFlow: jsPath + "/PageFlow.js",
App: "./App.js",
};
module.exports = {
entry: entryPoints,
output: {
path: path.resolve(__dirname, outputPath),
filename: "[name].js",
publicPath: "",
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new BrowserSyncPlugin(
{
server: { baseDir: './' },
files: [outputPath + "/*.css", "./*.html", "./**/*.js", "./**/*.css"],
injectCss: true,
},
{ reload: false }
),
],
module: {
rules: [
// {
// test: /\.tsx?$/,
// use: 'ts-loader',
// exclude: /node_modules/,
// },
{
test: /\.s?[c]ss$/i,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
{
test: /\.sass$/i,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: {
sassOptions: { indentedSyntax: true },
},
},
],
},
{
test: /\.(gif)$/i,
use: "url-loader?limit=1024",
},
],
},
optimization: {
minimize: true,
minimizer: [
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
// `...`,
new CssMinimizerPlugin(),
new TerserPlugin({ parallel: true }),
],
},
// resolve: {
// extensions: ['.tsx', '.ts', '.js'],
// },
};