123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- const modifyVars = require("./src/styles/theme-antd");
- const path = require('path');
- const fs = require('fs');
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
- const getDirectories = (source) =>
- fs
- .readdirSync(source, { withFileTypes: true })
- .filter((dirent) => dirent.isDirectory())
- .map((dirent) => dirent.name);
- const getAlias = (alias, path) => {
- const aliases = {};
- const dirs = getDirectories(path);
- dirs.forEach((dir) => (aliases[`${alias}/${dir}`] = `${path}/${dir}`));
- return aliases;
- };
- const aliases = getAlias('@', path.resolve(__dirname, './src'));
- module.exports = {
- publicPath: "./",
- // process.env.NODE_ENV === 'production'
- // ? `//infishwaibao.oss-cn-chengdu.aliyuncs.com/bess/`
- // : './',
- lintOnSave: false,
- pages: {
- index: {
- entry: 'src/pages/website/main.ts',
- template: 'public/index.html',
- filename: 'index.html',
- chunks: ['chunk-vendors', 'chunk-common', 'index']
- },
- frame3d: {
- entry: 'src/pages/frame3d/main.ts',
- template: 'public/index.html',
- filename: 'frame3d.html',
- chunks: ['chunk-vendors', 'chunk-common', 'frame3d']
- },
- },
- css: {
- loaderOptions: {
- less: {
- lessOptions: {
- modifyVars,
- javascriptEnabled: true,
- },
- },
- },
- },
- chainWebpack: (config) => {
- // if (process.env.NODE_ENV === 'production') {
- // config.plugin('extract-css').tap((args) => {
- // args[0].ignoreOrder = true;
- // return args;
- // });
- // config.optimization.minimizer('terser').tap(args => {
- // Object.assign(args[0].terserOptions.compress, {
- // pure_funcs: ['console.log']
- // })
- // return args
- // })
- // }
- const tsRule = config.module.rule("ts");
- tsRule
- .use("moduse-loader")
- .loader("moduse/webpack-loader")
- .options({
- include: [
- path.resolve(__dirname, "./src/modules"),
- path.resolve(__dirname, "./node_modules/@queenjs-modules"),
- ],
- });
- },
- configureWebpack: {
- module: {
- rules: [
- {
- test: /\.(tsx)$/,
- use: [
- {
- loader: '@linaria/webpack-loader',
- options: {
- sourceMap: process.env.NODE_ENV !== 'production',
- babelOptions: {
- plugins: [
- [
- 'babel-plugin-module-resolver',
- {
- root: ['.'], //the value mentioned in the path section of the `tsconfig.json based on your CWD`
- extensions: ['.tsx', '.ts'],
- alias: aliases, //The important part!!
- },
- ],
- ],
- },
- },
- },
- ],
- }, {
- test: /\.svga$/,
- use: [{ loader: 'file-loader' }],
- },
- {
- test: /\.(frag|vert|glsl)$/,
- use: [{ loader: 'raw-loader' }],
- }, {
- test: /\.(glb)$/,
- use: [{ loader: 'url-loader' }],
- },
- ],
- },
- },
- };
|