projekt-sklep/webpack.config.js

88 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-09-06 14:34:28 +02:00
const path = require("path");
const process = require("process");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const mode = process.env.NODE_ENV || "development";
const src = path.resolve(__dirname, "src");
module.exports = {
entry: {
index: path.join(src, "index.ts"),
},
mode: mode,
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.(c|s[ac])ss$/i,
use: [
{
loader: "file-loader",
2020-10-01 20:34:30 +02:00
options: {
name: "[name].css",
},
2020-09-06 14:34:28 +02:00
},
2020-10-01 20:34:30 +02:00
"extract-loader",
"css-loader",
"resolve-url-loader",
2020-09-06 14:34:28 +02:00
"sass-loader",
],
},
2020-10-01 20:34:30 +02:00
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "fontello/",
esModule: false,
},
},
],
},
2020-09-06 14:34:28 +02:00
{
2020-10-02 22:32:36 +02:00
test: /\.(html|php)$/,
2020-09-06 14:34:28 +02:00
use: [
"html-loader",
{
loader: "posthtml-loader",
options: {
plugins: [
/* PostHTML Plugins */
2020-10-01 20:34:30 +02:00
require("posthtml-extend")({
root: src,
}),
2020-09-06 14:34:28 +02:00
],
2020-10-02 22:32:36 +02:00
directives: [
{ name: "?php", start: "<", end: ">" },
{ name: "?=", start: "<", end: ">" },
],
2020-09-06 14:34:28 +02:00
},
},
],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
plugins: [
new HtmlWebpackPlugin({
filename: "index.html",
template: path.resolve(src, "index.html"),
chunks: ["index"],
}),
],
};