fingerprintjs

Форк
0
/
webpack.config.ts 
62 строки · 1.7 Кб
1
import { ConfigOptions } from 'webpack-cli'
2
import { Configuration as DevServer } from 'webpack-dev-server'
3
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
4
import * as TerserPlugin from 'terser-webpack-plugin'
5
import terserConfig from '../terser.config'
6

7
const configurationFactory: ConfigOptions = (_env, { mode = 'development' }) => ({
8
  entry: './index.ts',
9
  mode,
10
  resolve: {
11
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
12
  },
13
  module: {
14
    rules: [
15
      {
16
        test: /\.tsx?$/i,
17
        loader: 'ts-loader',
18
        exclude: /node_modules/,
19
        options: {
20
          compilerOptions: {
21
            sourceMap: true,
22
          },
23
        },
24
      },
25
      {
26
        test: /\.(jpe?g|png|svg|ico)$/i,
27
        loader: 'file-loader',
28
        options: {
29
          outputPath: 'assets',
30
          name: '[name].[ext]?[contenthash]',
31
        },
32
      },
33
    ],
34
  },
35
  optimization: {
36
    minimizer: [
37
      new TerserPlugin({
38
        terserOptions: terserConfig,
39
      }),
40
    ],
41
  },
42
  devtool: mode === 'development' ? 'inline-source-map' : 'source-map',
43
  output: {
44
    clean: true,
45
    filename: '[name].js?[contenthash]',
46
  },
47
  devServer: {
48
    host: '0.0.0.0',
49
    allowedHosts: 'all',
50
  } satisfies DevServer,
51
  plugins: [
52
    new HtmlWebpackPlugin({
53
      template: './index.html',
54
      title: `FingerprintJS ${mode === 'development' ? 'Playground' : 'Demo'}`,
55
    }),
56
  ],
57
  // https://stackoverflow.com/a/71739898/1118709
58
  // Correct (but not worth effort) solutions: build-time macros, custom JSON loader, Rollup instead of Webpack, riot
59
  ignoreWarnings: [/Should not import the named export 'version' .* from default-exporting module/],
60
})
61

62
export default configurationFactory
63

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.