| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 | 'use strict'const MiniCssExtractPlugin = require("mini-css-extract-plugin");const { VueLoaderPlugin } = require('vue-loader')const ESLintPlugin = require('eslint-webpack-plugin');const ExtraneousFileCleanupPlugin = require('webpack-extraneous-file-cleanup-plugin');const CompressionPlugin = require("compression-webpack-plugin");const { CleanWebpackPlugin } = require('clean-webpack-plugin');const CircularDependencyPlugin = require('circular-dependency-plugin')const utils = require('./utils')const themePath = 'web/themes/custom/materiotheme'const langPath = 'web/sites/default/files/lang'const isDev = process.env.NODE_ENV === 'development';module.exports = {  resolve: {    extensions: ['.js', '.vue', '.json'],    alias: {      // 'vue': 'vue/dist/vue.js',      'vue' : isDev ? 'vue/dist/vue.js' : 'vue/dist/vue.min.js',      'theme': utils.resolve(themePath),      'vuejs': utils.resolve(themePath+'/vuejs'),      'assets': utils.resolve(themePath+'/assets'),      // locales are exported by strings_i18n_json_export from drupal      'locales': utils.resolve(langPath)    }  },  entry: {    'main': utils.resolve(themePath + '/assets/scripts/main.js'),    // 'lang-en': utils.resolve(langPath + '/en.json'),    'print': utils.resolve(themePath + '/assets/styles/print.scss')    // 'mdi': utils.resolve(themePath + '/assets/styles/mdi/scss/materialdesignicons.scss')  },  output: {    publicPath: '/themes/custom/materiotheme/assets/dist/',    path: utils.resolve(themePath + '/assets/dist/'),    filename: '[name].js',    chunkFilename: '[name].[chunkhash].bundle.js'  },  module: {    rules: [      // {      //   test: /\.(js|vue)$/,      //   loader: 'eslint-loader',      //   enforce: 'pre',      //   exclude: /node_modules/,      //   options: {      //     emitError: true,      //     emitWarning: true      //   }      // },      {        test: /\.vue$/,        use: 'vue-loader'      },      // {      //   resourceQuery: /blockType=i18n/,      //   type: 'javascript/auto',      //   loader: '@kazupon/vue-i18n-loader'      // },      // {      //   test: /\.js$/,      //   use: {      //     loader: 'babel-loader',      //   }      // },      {        test: /\.(graphql|gql)$/,        exclude: /node_modules/,        loader: 'graphql-tag/loader'      },      {        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,        use: {          loader: 'url-loader',          options: {            limit: 10000,            name: utils.assetsPath('fonts/[name].[hash:7].[ext]')          }        }      }      // {      //   test: /\.graphql?$/,      //   use: [      //     {      //       loader: 'webpack-graphql-loader',      //       options: {      //         // validate: true,      //         // schema: "./path/to/schema.json",      //         // removeUnusedFragments: true      //         // etc. See "Loader Options" below      //       }      //     }      //   ]      // }      // , {      //   test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,      //   use: {      //     loader: 'url-loader',      //     options: {      //       limit: 10000,      //       name: utils.assetsPath('img/[name].[hash:7].[ext]')      //     }      //   }      // }, {      //   test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,      //   use: {      //     loader: 'url-loader',      //     options: {      //       limit: 10000,      //       name: utils.assetsPath('media/[name].[hash:7].[ext]')      //     }      //   }      // }      // {      //   test: /\.css$/,      //   use: [MiniCssExtractPlugin.loader, 'css-loader'],      // },    ]  },  optimization: {    splitChunks: {      cacheGroups: {        // vsa: {        //   test: /[\\/]node_modules[\\/](vue-simple-accordion)[\\/]/,        //   name: 'vsa',        //   chunks: 'all',        //   usedExports: true        // },        vclb: {          test: /[\\/]node_modules[\\/](vue-cool-lightbox)[\\/]/,          name: 'vclb',          chunks: 'all',          usedExports: true        },        // vue_page_article: {        //   test: /[\\/]web[\\/]themes[\\/]custom[\\/]materiotheme[\\/]vuejs[\\/]components[\\/]Pages[\\/]Article.vue/,        //   name: 'vue_page_article',        //   chunks: 'all'        // }      },    },  },  plugins: [    new MiniCssExtractPlugin({      filename: '[name].css'    }),    new VueLoaderPlugin(),    new ESLintPlugin({      // fix: true      // exclude: ['web/.eslintrc.json']      // cache: false,      // ignore: true,      // useEslintrc: false,    }),    new ExtraneousFileCleanupPlugin({      extensions: ['.js'],      paths: [utils.resolve(themePath + '/assets/dist/')],      minBytes: 4096    }),    new CompressionPlugin(),    /**     * All files inside webpack's output.path directory will be removed once, but the     * directory itself will not be. If using webpack 4+'s default configuration,     * everything under <PROJECT_DIR>/dist/ will be removed.     * Use cleanOnceBeforeBuildPatterns to override this behavior.     *     * During rebuilds, all webpack assets that are not used anymore     * will be removed automatically.     *     * See `Options and Defaults` for information     */     new CleanWebpackPlugin(),     new CircularDependencyPlugin({      // exclude detection of files based on a RegExp      exclude: /a\.js|node_modules/,      // include specific files based on a RegExp      // include: /dir/,      // add errors to webpack instead of warnings      failOnError: false,      // allow import cycles that include an asyncronous import,      // e.g. via import(/* webpackMode: "weak" */ './file.js')      allowAsyncCycles: false,      // set the current working directory for displaying module paths      // cwd: process.cwd(),    })  ]}
 |