87 lines
1.6 KiB
JavaScript
87 lines
1.6 KiB
JavaScript
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",
|
|
options: {
|
|
name: "[name].css",
|
|
},
|
|
},
|
|
"extract-loader",
|
|
"css-loader",
|
|
"resolve-url-loader",
|
|
"sass-loader",
|
|
],
|
|
},
|
|
{
|
|
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
use: [
|
|
{
|
|
loader: "file-loader",
|
|
options: {
|
|
name: "[name].[ext]",
|
|
outputPath: "fontello/",
|
|
esModule: false,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
|
|
{
|
|
test: /\.(html|php)$/,
|
|
use: [
|
|
"html-loader",
|
|
{
|
|
loader: "posthtml-loader",
|
|
options: {
|
|
plugins: [
|
|
/* PostHTML Plugins */
|
|
require("posthtml-extend")({
|
|
root: src,
|
|
}),
|
|
],
|
|
directives: [
|
|
{ name: "?php", start: "<", end: ">" },
|
|
{ name: "?=", start: "<", end: ">" },
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
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"],
|
|
}),
|
|
],
|
|
};
|