aico-image-editor
Version: 
Combine multiple image into and create single combined image
162 lines (150 loc) • 4.2 kB
JavaScript
const path = require('path');
const webpack = require('webpack');
// const devMiddleware = require("webpack-dev-middleware");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
// const dev = process.env.NODE_ENV !== 'production'
module.exports = {
  devtool: 'source-map',
  plugins: [
    new MiniCssExtractPlugin({filename: './css/[name].css'}),
    // new webpack.DefinePlugin({
    //   'process.env.APP_URL': JSON.stringify('http://127.0.0.1')
    // })
  ],
  entry: {
    // app: [
    //   './src/js/app.js',
    //   './src/scss/store-locator-main.scss',
    //   './src/scss/store-locator-custom.scss'
    // ],
    index: {
      import: './src/index.js', 
      filename: "./js/[name].js",
      library: {
        // note there's no `name` here
        name: 'aicoEditor',
        type: 'umd',
      },
      
    },
    main: {import: './src/scss/main.scss'},
    custom: {import: './src/scss/custom.scss'},
    
  },
  output: {
    path: path.resolve(__dirname, './output/'),
    //publicPath: 'http://localhost:5700/output/',
    filename: "[name].js",
    //chunkFilename: 'js/aico-image-editor/[id].js',
    clean: true,
  },
  module: {
    rules: [
      {
        test: /\.html$/i,
        type: 'asset/source',
        
      },
      {
        test: /\.(sass|scss)$/,
        use: [
          {
            
            loader: 'style-loader',
          },
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              esModule: false,
              publicPath: '../'
            },
          },
          {
            
            loader: 'css-loader',
            options: {
              //sourceMap: false,
              sourceMap: true,
            },
          },
          {
            loader: 'sass-loader',
            options: {
              api: "modern",
              implementation: require("sass"),
              sourceMap: true,
              sassOptions: {
                //outputStyle: 'compressed'
                //includePaths: [path.resolve(__dirname, 'node_modules')]
              }
            },
          },
          
        ]
      },
      {
        test: /\.css$/i,
        use: [
          {
            loader: 'css-loader',
            options: {
              sourceMap: true,
              exportType: "css-style-sheet"
            } 
          }
        ],
      },
      {
        test: /\.(ttf|woff|woff2|eot|svg)$/,
        exclude: /node_modules/,
        include: [path.resolve(__dirname, "fonts")],
        type: 'asset/resource',
        generator: {
          filename: 'fonts/aico-image-editor/[name][ext]',
          //publicPath: process.env.APP_URL + '/'
        }
      },
      {
        test: /\.(jpg|png|svg|gif)$/,
        exclude: /node_modules/,
        include: [path.resolve(__dirname, "images")],
        type: 'asset/resource',
        generator: {
          filename: 'images/aico-image-editor/[name][ext]',
          //publicPath: process.env.APP_URL + '/'
        }
      },
    ]
  },
  externals: [
    {
      'bootstrap/js/dist/dropdown': 'bootstrap.Dropdown',
      'bootstrap/js/dist/tab': 'bootstrap.Tab',
      'bootstrap/js/dist/tooltip': 'bootstrap.Tooltip',
      'bootstrap/js/dist/modal': 'bootstrap.Modal',
      'alpinejs': 'Alpine',
      '@alpinejs/persist': 'persist',
      '@alpinejs/intersect': 'intersect',
      'fabric': 'fabric'
    }
  ],
  // optimization: {
  //   splitChunks: {
  //     chunks: 'all',
  //     cacheGroups: {
  //       vendor: {
  //         test: /[\\/]node_modules[\\/]/,
  //         name: 'vendors',
  //         chunks: 'all',
  //         maxSize: 500000, // Limit vendor chunks to 500KB
  //       },
  //       styles: {
  //         test: /(\.css)$/, // Matches any CSS file
  //         name: 'styles',
  //         chunks: 'all',
  //         enforce: true, // Ensures that the chunk is created even if it's not larger than minSize
  //         maxSize: 500000, // Limit the chunk size to 200KB
  //       },
  //     },
  //   },
  // },
  //externalsType: 'commonjs'
 
  // snapshot: {
  //   managedPaths: [],
  // }
};