build: worker 内联打包添补 (#1338)

This commit is contained in:
lvisei 2022-09-15 10:18:25 +08:00 committed by GitHub
parent 7d796a1940
commit 3e7ab354ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 47 deletions

View File

@ -1,31 +1,23 @@
export default { export default {
// more father 4 config: https://github.com/umijs/father-next/blob/master/docs/config.md // more father 4 config: https://github.com/umijs/father-next/blob/master/docs/config.md
esm: { esm: {
output:'es' output: 'es',
}, },
cjs: { cjs: {
output:'lib' output: 'lib',
}, },
transformer:'babel', transformer: 'babel',
autoprefixer: { autoprefixer: {
browsers: ['IE 11', 'last 2 versions'], browsers: ['IE 11', 'last 2 versions'],
}, },
extraBabelPresets: [ extraBabelPresets: ['@babel/preset-typescript'],
'@babel/preset-typescript'
],
extraBabelPlugins: [ extraBabelPlugins: [
// 开发模式下以原始文本引入,便于调试 // 开发模式下以原始文本引入,便于调试
[ [
// import glsl as raw text // import glsl as raw text
'babel-plugin-inline-import', 'babel-plugin-inline-import',
{ { extensions: ['.glsl'] },
extensions: [
'.glsl'
]
}
],
[
'transform-import-css-l7'
], ],
['transform-import-css-l7'],
], ],
}; };

View File

@ -5,42 +5,42 @@ export default defineConfig({
favicon: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png', favicon: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png',
logo: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png', logo: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png',
outputPath: 'docs-dist', outputPath: 'docs-dist',
base:'/', base: '/',
devServer:{ devServer: {
port:'6006', port: '6006',
}, },
resolve: { resolve: {
includes: ['dev-demos'] includes: ['dev-demos'],
}, },
polyfill: { polyfill: {
imports: [ imports: ['element-remove', 'babel-polyfill'],
'element-remove',
'babel-polyfill',
]
}, },
targets: { targets: {
chrome: 58, chrome: 58,
ie: 11, ie: 11,
}, },
mode: 'site', mode: 'site',
esbuild:false, esbuild: false,
chainWebpack:(memo, { env, webpack, createCSSRule })=> { chainWebpack: (memo, { env, webpack, createCSSRule }) => {
// 设置 alias // 设置 alias
memo.module memo.module
.rule('lint') .rule('lint')
.test(/\.glsl$/) .test(/\.glsl$/)
.use('babel') .use('babel')
.loader('ts-shader-loader') .loader('ts-shader-loader');
// 还可以创建具名use (loaders) // 还可以创建具名use (loaders)
}, },
extraBabelPresets:[ extraBabelPresets: ['@babel/preset-typescript'],
'@babel/preset-typescript' extraBabelIncludes: [
'@umijs/preset-dumi',
'split-on-first',
'query-string',
'strict-uri-encode',
'copy-text-to-clipboard',
], ],
extraBabelIncludes: ['@umijs/preset-dumi','split-on-first','query-string','strict-uri-encode','copy-text-to-clipboard'],
extraBabelPlugins: [ extraBabelPlugins: [
[ ['transform-import-css-l7'],
'transform-import-css-l7' ['babel-plugin-inline-import', { extensions: ['.worker.js'] }],
],
], ],
navs: [ navs: [
null, null,
@ -54,7 +54,7 @@ export default defineConfig({
'react-dom': 'window.ReactDOM', 'react-dom': 'window.ReactDOM',
antd: 'window.antd', antd: 'window.antd',
lodash: '_', lodash: '_',
fetch:"window.fetch" fetch: 'window.fetch',
}, },
links: ['https://gw.alipayobjects.com/os/lib/antd/4.16.13/dist/antd.css'], links: ['https://gw.alipayobjects.com/os/lib/antd/4.16.13/dist/antd.css'],
scripts: [ scripts: [

View File

@ -1,30 +1,22 @@
export default { export default {
// more father 4 config: https://github.com/umijs/father-next/blob/master/docs/config.md // more father 4 config: https://github.com/umijs/father-next/blob/master/docs/config.md
esm: { esm: {
output:'es' output: 'es',
}, },
cjs: { cjs: {
output:'lib' output: 'lib',
}, },
autoprefixer: { autoprefixer: {
browsers: ['IE 11', 'last 2 versions'], browsers: ['IE 11', 'last 2 versions'],
}, },
extraBabelPresets: [ extraBabelPresets: ['@babel/preset-typescript'],
'@babel/preset-typescript'
],
extraBabelPlugins: [ extraBabelPlugins: [
// 开发模式下以原始文本引入,便于调试 // 开发模式下以原始文本引入,便于调试
[ [
// import glsl as raw text // import glsl as raw text
'babel-plugin-inline-import', 'babel-plugin-inline-import',
{ { extensions: ['.glsl', '.worker.js'] },
extensions: [
'.glsl'
]
}
],
[
'transform-import-css-l7'
], ],
['transform-import-css-l7'],
], ],
}; };