Skip to content

Commit

Permalink
Babel build
Browse files Browse the repository at this point in the history
  • Loading branch information
plesiecki committed Mar 1, 2022
1 parent 370a088 commit 2819bd9
Show file tree
Hide file tree
Showing 8 changed files with 2,217 additions and 19,451 deletions.
44 changes: 44 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = api => {
api.cache(true);
return {
env: {
legacy: {
passPerPreset: true,
presets: [
"@babel/preset-typescript",
["@babel/preset-env", {
modules: false,
targets: "> 0.25%, last 2 versions, Firefox ESR",
}],
["@babel/preset-react", {
development: false,
useBuiltIns: true,
}]
],
plugins: [
"@babel/plugin-proposal-class-properties"
]
},
modern: {
passPerPreset: true,
presets: [
"@babel/preset-typescript",
["@babel/preset-env", {
modules: false,
targets: {
esmodules: true,
},
bugfixes: true,
}],
["@babel/preset-react", {
development: false,
useBuiltIns: true,
}]
],
plugins: [
"@babel/plugin-proposal-class-properties"
]
}
}
}
}
40 changes: 10 additions & 30 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ const path = require("path");

const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const babelLoader = {
loader: "babel-loader",
options: {
presets: [
["@babel/preset-env", {
modules: false
}]
]
}
};

module.exports = {
devtool: "source-map",
output: {
Expand All @@ -49,38 +38,29 @@ module.exports = {
test: /\.js$/,
use: ["source-map-loader"]
},
{
test: /\.js?$/,
use: [
babelLoader
]
},
{
test: /\.tsx?$/,
use: [
babelLoader,
{
loader: "ts-loader",
options: {
configFile: "src/client/tsconfig.json"
}
}
]
use: [{
loader: "babel-loader",
options: {
envName: "modern",
},
}],
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader"
]
],
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader"
]
],
},
{
test: /\.(woff|woff2)$/i,
Expand All @@ -94,7 +74,7 @@ module.exports = {
{
test: /\.svg$/,
use: ["svg-inline-loader"]
}
]
},
],
}
};
4 changes: 2 additions & 2 deletions config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

const common = require("./webpack.common");
const commonConfig = require("./webpack.common");
const merge = require("webpack-merge");
const webpack = require('webpack');
const hotMiddlewareScript = 'webpack-hot-middleware/client';

module.exports = merge.smart(common, {
module.exports = merge.smart(commonConfig, {
mode: 'development',
entry: {
main: [hotMiddlewareScript, "./src/client/main.tsx"]
Expand Down
30 changes: 27 additions & 3 deletions config/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
* limitations under the License.
*/

const common = require('./webpack.common');
const commonConfig = require('./webpack.common');
const merge = require('webpack-merge');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');

module.exports = merge.smart(common, {
const prodConfig = {
name: "client-modern",
mode: "production",
entry: {
main: "./src/client/main.tsx",
Expand All @@ -35,4 +36,27 @@ module.exports = merge.smart(common, {
'process.env.NODE_ENV': JSON.stringify('production')
}),
]
});
};

const es5Config = {
module: {
rules: [{
test: /\.tsx?$/,
use: [{
loader: "babel-loader",
options: {
envName: "legacy",
},
}],
}]
},
name: "client-legacy",
output: {
filename: "[name].es5.js",
}
};

module.exports = [
merge.smart(commonConfig, prodConfig),
merge.smart(commonConfig, prodConfig, es5Config),
]
Loading

0 comments on commit 2819bd9

Please sign in to comment.