webpack.config.npm.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const path = require('path')
  2. const CleanWebpackPlugin = require('clean-webpack-plugin')
  3. module.exports = {
  4. mode: 'production',
  5. entry: {
  6. index: './src/index.js',
  7. },
  8. output: {
  9. path: path.resolve(__dirname, '../lib'),
  10. filename: '[name].js',
  11. libraryTarget: 'commonjs2',
  12. },
  13. module: {
  14. rules: [
  15. {
  16. test: /\.js$/,
  17. loader: 'babel-loader',
  18. exclude: /node_modules/,
  19. },
  20. {
  21. test: /\.css$/,
  22. use: [
  23. 'style-loader',
  24. {
  25. loader: 'css-loader',
  26. options: {
  27. modules: true,
  28. camelCase: true,
  29. localIdentName: '[name]__[local]--[hash:base64:5]',
  30. },
  31. },
  32. 'postcss-loader',
  33. ],
  34. },
  35. {
  36. test: /\.(jpe?g|png|svg|bmp)$/,
  37. loader: 'file-loader',
  38. options: {
  39. outputPath: 'images/',
  40. publicPath: '/lib/images/',
  41. name: '[name].[ext]',
  42. },
  43. },
  44. ],
  45. },
  46. plugins: [
  47. new CleanWebpackPlugin(['lib']),
  48. ],
  49. }