I'm working on a WordPress website that uses the Swiper library, on several pages, as an npm dependency. Included in the website is an embedded Vue CLI 4 app, that I'd also like to add the Swiper library to. Currently, the website has its own webpack config, while the app uses a slightly modified version of its default build config.
There are Vue Swiper components that I could use but, as I'm already using the original library, I'd like to avoid duplication. I assume I'd need to somehow combine my two build processes (unless there's another solution), but I've not attempted anything like that before.
The main webpack config is as follows:
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = (env, options) => {
    return {
        entry: {
            main: ["./src/js/index.js", "./src/scss/index.scss"],
            admin: ["./src/scss/admin.scss", "./src/js/admin/index.js"]
        },
        output: {
            path: path.resolve(__dirname, "dist"),
            filename: "[name].js",
            publicPath: "/dist"
        },
        module: {
            rules: [
                {
                    test: /\.js$/,
                    use: {
                        loader: "babel-loader",
                        options: { presets: ["@babel/preset-env"] }
                    }
                },
                {
                    test: /\.scss$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        "css-loader",
                        "sass-loader"
                    ]
                },
                {
                    test: /\.svg$/,
                    use: {
                        loader: 'file-loader',
                        options: {
                            name: '[name].[ext]',
                            outputPath: '/images',
                            publicPath(url) {
                                return `/wp-content/themes/themename/dist/images/${url}`
                            },
                        },
                    }
                },
            ]
        },
        plugins: [
            new MiniCssExtractPlugin({
                filename: "[name].css"
            })
        ]
    }
};
And the directory structure:
├── app
|   ├── src
|   ├── dist
|   ├── ...
|   └── vue.config.js
├── src
├── dist
├── ...
└── webpack.config.js
Ideally, I'd like to keep the directories as they are, so how would I be able to use Swiper in both projects, without having it duplicated across both bundles?
 
     
    