Skip to content

Commit

Permalink
overwrite webpack config module.rules to avoid duplicate match on sou…
Browse files Browse the repository at this point in the history
…rce files
  • Loading branch information
kevinwilde-at committed Jul 7, 2022
1 parent cf932eb commit dc6bd07
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions bundler.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
const createBundler = require('@airtable/blocks-webpack-bundler').default;

function createConfig(baseConfig) {
baseConfig.module.rules.push({
test: /\.tsx$/,
exclude: [/node_modules/],
loader: 'babel-loader',
options: {
babelrc: false,
configFile: false,
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-react'),
require.resolve('@babel/preset-typescript'),
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": false }]
// In contrast to MobX 4/5, "loose" must be false! ^
]
},
});
baseConfig.module.rules = [
{

This comment has been minimized.

Copy link
@kevinwilde-at

kevinwilde-at Jul 7, 2022

Author Owner

Add other rules as needed, eg. if you are importing css files and want webpack to handle them, add a rule such as

{
    test: /\.css$/,
    use: [require.resolve('style-loader'), require.resolve('css-loader')],
}
test: /\.tsx$/,
exclude: [/node_modules/],
loader: 'babel-loader',
options: {
babelrc: false,
configFile: false,
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-react'),
require.resolve('@babel/preset-typescript'),
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": false }]
// In contrast to MobX 4/5, "loose" must be false! ^
]
},
}
];
return baseConfig;
}

Expand Down

0 comments on commit dc6bd07

Please sign in to comment.