49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import path from 'path';
|
|
|
|
import { createConfig } from 'ksv741-react-scripts';
|
|
import { InjectManifest } from 'workbox-webpack-plugin';
|
|
|
|
import type { WebpackEnv } from 'ksv741-react-scripts';
|
|
import type { WebpackOptions } from 'ksv741-react-scripts/dist/types';
|
|
|
|
const config = (env: WebpackEnv) => {
|
|
const baseConfig = createConfig({
|
|
analyze: Boolean(env.analyze),
|
|
mode: env.mode ?? 'development',
|
|
devServer: {
|
|
port: 3003,
|
|
},
|
|
plugins: {
|
|
htmlWebpackPlugin: {
|
|
favicon: path.resolve(__dirname, 'public', 'favicon.png'),
|
|
},
|
|
copyPlugin: {
|
|
patterns: [
|
|
{
|
|
from: path.resolve(__dirname, 'public', 'assets', 'icons'),
|
|
to: path.resolve(__dirname, 'build', 'static', 'icons'),
|
|
},
|
|
{
|
|
from: path.resolve(__dirname, 'public', 'assets', 'screenshots'),
|
|
to: path.resolve(__dirname, 'build', 'static', 'screenshots'),
|
|
},
|
|
],
|
|
},
|
|
},
|
|
} as WebpackOptions);
|
|
|
|
if (env.mode === 'production') {
|
|
const swPlugin = new InjectManifest({
|
|
swSrc: './src/src-sw.js',
|
|
swDest: 'sw.js',
|
|
});
|
|
|
|
// @ts-ignore
|
|
baseConfig.plugins.push(swPlugin);
|
|
}
|
|
|
|
return baseConfig;
|
|
};
|
|
|
|
export default config;
|