Skip to content

Commit

Permalink
Be able to compile the project without typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Sep 18, 2024
1 parent 8ff149f commit 8127f0e
Showing 1 changed file with 40 additions and 46 deletions.
86 changes: 40 additions & 46 deletions buildtools/webpack.commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,30 @@ module.exports = function (config) {
$: 'jquery',
});

const rules = [];

// Expose corejs-typeahead as window.Bloodhound
const typeaheadRule = {
rules.push({
test: require.resolve('corejs-typeahead'),
use: {
loader: 'expose-loader',
options: {
exposes: 'Bloodhound',
},
},
};
});

const jqueryRule = {
rules.push({
test: require.resolve('jquery'),
use: {
loader: 'expose-loader',
options: {
exposes: '$',
},
},
};
});

const gmfapiExpose = {
rules.push({
test: path.resolve(__dirname, '../srcapi/index.ts'),
use: {
loader: 'expose-loader',
Expand All @@ -79,57 +81,59 @@ module.exports = function (config) {
},
},
},
};

const jsRule = {
test: /MapillaryService\.js$/,
use: [
{
loader: 'magic-comments-loader',
},
],
};

const tsRule = {
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
},
{
loader: 'minify-html-literals-loader',
},
],
};
});

const cssRule = {
rules.push({
test: /\.css$/,
use: [{loader: 'style-loader'}, {loader: 'css-loader'}],
};
});

const sassRule = {
rules.push({
test: /\.s[ac]ss$/i,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{loader: 'sass-loader', options: {warnRuleAsWarning: false}},
],
};
});

const resourcesRule = {
rules.push({
test: /\.(jpeg|png|ico|eot|ttf|woff|woff2|svg|json)$/,
type: 'asset/resource',
};
});

const htmlRule = {
rules.push({
test: /\.html$/,
use: {
loader: 'ejs-loader',
options: {
esModule: false,
},
},
};
});

if (config.noTs != true) {
rules.push({
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
},
{
loader: 'minify-html-literals-loader',
},
],
});
}

rules.push({
test: /MapillaryService\.js$/,
use: [
{
loader: 'magic-comments-loader',
},
],
});

const plugins = [
providePlugin,
Expand All @@ -155,17 +159,7 @@ module.exports = function (config) {
path: path.resolve(__dirname, '../dist/'),
},
module: {
rules: [
typeaheadRule,
jqueryRule,
gmfapiExpose,
cssRule,
sassRule,
resourcesRule,
htmlRule,
tsRule,
jsRule,
],
rules: rules,
},
plugins: plugins,
resolve: {
Expand Down

0 comments on commit 8127f0e

Please sign in to comment.