build(frontend): use polyfill and babel esbuild plugins
This commit is contained in:
parent
864852311d
commit
494be2d8dd
@ -1,5 +1,6 @@
|
|||||||
import * as esbuild from 'esbuild';
|
import * as esbuild from 'esbuild';
|
||||||
|
|
||||||
|
import babel from 'esbuild-plugin-babel';
|
||||||
import { sassPlugin } from 'esbuild-sass-plugin';
|
import { sassPlugin } from 'esbuild-sass-plugin';
|
||||||
// import svgPlugin from 'esbuild-plugin-svg-bundle';
|
// import svgPlugin from 'esbuild-plugin-svg-bundle';
|
||||||
import svgPlugin from 'esbuild-plugin-svg';
|
import svgPlugin from 'esbuild-plugin-svg';
|
||||||
@ -8,9 +9,11 @@ import { copy } from 'esbuild-plugin-copy';
|
|||||||
import manifestPlugin from 'esbuild-plugin-assets-manifest';
|
import manifestPlugin from 'esbuild-plugin-assets-manifest';
|
||||||
import copyWithHashPlugin from '@enonic/esbuild-plugin-copy-with-hash';
|
import copyWithHashPlugin from '@enonic/esbuild-plugin-copy-with-hash';
|
||||||
import inlineImportPlugin from 'esbuild-plugin-inline-import';
|
import inlineImportPlugin from 'esbuild-plugin-inline-import';
|
||||||
|
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
|
||||||
|
|
||||||
const staticDir = './static';
|
const staticDir = './static';
|
||||||
const wellKnownDir = './well-known';
|
const wellKnownDir = './well-known';
|
||||||
|
const wellKnownDirs = [ `${wellKnownDir}/de-de-formal`, `${wellKnownDir}/en-eu` ];
|
||||||
|
|
||||||
await esbuild.build({
|
await esbuild.build({
|
||||||
bundle: true,
|
bundle: true,
|
||||||
@ -22,6 +25,9 @@ await esbuild.build({
|
|||||||
},
|
},
|
||||||
outdir: staticDir,
|
outdir: staticDir,
|
||||||
plugins: [
|
plugins: [
|
||||||
|
nodeModulesPolyfillPlugin({
|
||||||
|
// modules: ['crypto','worker_threads']
|
||||||
|
}),
|
||||||
sassPlugin(),
|
sassPlugin(),
|
||||||
svgPlugin({
|
svgPlugin({
|
||||||
minify: true,
|
minify: true,
|
||||||
@ -32,14 +38,14 @@ await esbuild.build({
|
|||||||
resolveFrom: 'cwd',
|
resolveFrom: 'cwd',
|
||||||
assets: {
|
assets: {
|
||||||
from: [ './assets/favicons/*' ],
|
from: [ './assets/favicons/*' ],
|
||||||
to: [ `${wellKnownDir}/de-de-formal`, `${wellKnownDir}/en-eu` ],
|
to: wellKnownDirs,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
copy({
|
copy({
|
||||||
resolveFrom: 'cwd',
|
resolveFrom: 'cwd',
|
||||||
assets: {
|
assets: {
|
||||||
from: [ './config/robots.txt' ],
|
from: [ './config/robots.txt' ],
|
||||||
to: [ `${wellKnownDir}/de-de-formal`, `${wellKnownDir}/en-eu` ],
|
to: wellKnownDirs,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// ...['de-de-formal','en-eu'].map((lang) => manifestPlugin({
|
// ...['de-de-formal','en-eu'].map((lang) => manifestPlugin({
|
||||||
@ -61,5 +67,23 @@ await esbuild.build({
|
|||||||
'./config/robots.txt',
|
'./config/robots.txt',
|
||||||
],
|
],
|
||||||
}), */
|
}), */
|
||||||
|
babel({
|
||||||
|
config: {
|
||||||
|
"sourceMaps": "inline",
|
||||||
|
"presets": [
|
||||||
|
"@babel/preset-env",
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
["@babel/plugin-proposal-decorators", { "legacy": true }],
|
||||||
|
["@babel/plugin-syntax-dynamic-import"],
|
||||||
|
["@babel/plugin-transform-class-properties", { "loose": true }],
|
||||||
|
["@babel/plugin-transform-private-methods", { "loose": true }],
|
||||||
|
["@babel/plugin-transform-private-property-in-object", { "loose": true }],
|
||||||
|
["@babel/plugin-transform-modules-commonjs"],
|
||||||
|
["@babel/transform-runtime"],
|
||||||
|
["@babel/plugin-syntax-jsx"],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue
Block a user