mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
79 lines
2.0 KiB
JavaScript
79 lines
2.0 KiB
JavaScript
const path = require("path");
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
const webpackBase = require("../build-scripts/webpack.js");
|
|
|
|
const isProd = process.env.NODE_ENV === "production";
|
|
const chunkFilename = isProd ? "chunk.[chunkhash].js" : "[name].chunk.js";
|
|
const buildPath = path.resolve(__dirname, "dist");
|
|
const publicPath = isProd ? "./" : "http://localhost:8080/";
|
|
const latestBuild = true;
|
|
|
|
module.exports = {
|
|
mode: isProd ? "production" : "development",
|
|
// Disabled in prod while we make Home Assistant able to serve the right files.
|
|
// Was source-map
|
|
devtool: isProd ? "none" : "inline-source-map",
|
|
entry: "./src/entrypoint.js",
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
{
|
|
loader: "ts-loader",
|
|
options: {
|
|
compilerOptions: latestBuild
|
|
? { noEmit: false }
|
|
: { target: "es5", noEmit: false },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: "raw-loader",
|
|
},
|
|
{
|
|
test: /\.(html)$/,
|
|
use: {
|
|
loader: "html-loader",
|
|
options: {
|
|
exportAsEs6Default: true,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
optimization: webpackBase.optimization(latestBuild),
|
|
plugins: [
|
|
new CopyWebpackPlugin([
|
|
"public",
|
|
{ from: "../public", to: "static" },
|
|
{ from: "../build-translations/output", to: "static/translations" },
|
|
{
|
|
from: "../node_modules/leaflet/dist/leaflet.css",
|
|
to: "static/images/leaflet/",
|
|
},
|
|
{
|
|
from: "../node_modules/roboto-fontface/fonts/roboto/*.woff2",
|
|
to: "static/fonts/roboto/",
|
|
},
|
|
{
|
|
from: "../node_modules/leaflet/dist/images",
|
|
to: "static/images/leaflet/",
|
|
},
|
|
]),
|
|
].filter(Boolean),
|
|
resolve: webpackBase.resolve,
|
|
output: {
|
|
filename: "[name].js",
|
|
chunkFilename: chunkFilename,
|
|
path: buildPath,
|
|
publicPath,
|
|
},
|
|
devServer: {
|
|
contentBase: "./public",
|
|
},
|
|
};
|