Bring back babel for ES5 builds (#3797)

* Bring back babel for ES5 builds

* Remove ts from babel
This commit is contained in:
Bram Kragten
2019-09-23 13:15:12 -07:00
committed by Paulus Schoutsen
parent 993d390ea5
commit a1b9a092d0
7 changed files with 617 additions and 237 deletions
+39 -29
View File
@@ -1,6 +1,7 @@
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpackBase = require("../build-scripts/webpack.js");
const { babelLoaderConfig } = require("../build-scripts/babel.js");
const isProd = process.env.NODE_ENV === "production";
const chunkFilename = isProd ? "chunk.[chunkhash].js" : "[name].chunk.js";
@@ -8,6 +9,43 @@ const buildPath = path.resolve(__dirname, "dist");
const publicPath = isProd ? "./" : "http://localhost:8080/";
const latestBuild = true;
const rules = [
{
exclude: [path.resolve(__dirname, "../node_modules")],
test: /\.ts$/,
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,
},
},
},
];
if (!latestBuild) {
rules.push(babelLoaderConfig({ latestBuild }));
}
module.exports = {
mode: isProd ? "production" : "development",
// Disabled in prod while we make Home Assistant able to serve the right files.
@@ -15,35 +53,7 @@ module.exports = {
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,
},
},
},
],
rules,
},
optimization: webpackBase.optimization(latestBuild),
plugins: [