您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

webpack.overlay.conf.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * @Author: Caven
  3. * @Date: 2020-01-18 18:22:23
  4. * @Last Modified by: Caven
  5. * @Last Modified time: 2020-04-09 20:49:23
  6. */
  7. const path = require('path')
  8. const webpack = require('webpack')
  9. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  10. const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
  11. function resolve(dir) {
  12. return path.join(__dirname, '.', dir)
  13. }
  14. module.exports = env => {
  15. const IS_PROD = (env && env.production) || false
  16. const publicPath = IS_PROD ? '/' : '/'
  17. let plugins = [
  18. new MiniCssExtractPlugin({
  19. filename: IS_PROD ? '[name].min.css' : '[name].css',
  20. allChunks: true
  21. })
  22. ]
  23. if (IS_PROD) {
  24. plugins.push(new OptimizeCssAssetsPlugin())
  25. plugins.push(new webpack.NoEmitOnErrorsPlugin())
  26. }
  27. return {
  28. entry: {
  29. 'dc.overlay': ['entry']
  30. },
  31. devtool: IS_PROD ? false : 'cheap-module-eval-source-map',
  32. output: {
  33. filename: IS_PROD ? '[name].min.js' : '[name].js',
  34. path: path.resolve(__dirname, 'dist/dc-sdk/overlay'),
  35. publicPath: publicPath,
  36. sourcePrefix: ''
  37. },
  38. amd: {
  39. toUrlUndefinded: true
  40. },
  41. node: {
  42. fs: 'empty'
  43. },
  44. module: {
  45. unknownContextCritical: false,
  46. rules: [
  47. {
  48. test: /\.js$/,
  49. exclude: /node_modules/,
  50. loader: 'babel-loader',
  51. query: {
  52. presets: ['@babel/preset-env'],
  53. compact: false,
  54. ignore: ['checkTree']
  55. }
  56. },
  57. {
  58. test: /\.css$/,
  59. use: [
  60. MiniCssExtractPlugin.loader,
  61. {
  62. loader: 'css-loader'
  63. },
  64. {
  65. loader: 'sass-loader'
  66. }
  67. ]
  68. },
  69. {
  70. test: /\.scss$/,
  71. use: [
  72. MiniCssExtractPlugin.loader,
  73. {
  74. loader: 'css-loader'
  75. },
  76. {
  77. loader: 'sass-loader'
  78. }
  79. ]
  80. },
  81. {
  82. test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
  83. loader: 'url-loader',
  84. options: {
  85. limit: 20000
  86. }
  87. }
  88. ]
  89. },
  90. resolve: {
  91. extensions: ['.js', '.json', '.css'],
  92. alias: {
  93. '@': resolve('src'),
  94. entry: './src/overlay'
  95. }
  96. },
  97. plugins
  98. }
  99. }