视频播放器仓库

generateConfig.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const path = require('path');
  2. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  3. const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
  4. const pkg = require('./package.json');
  5. const srcPath = path.resolve(__dirname, 'src');
  6. const distPath = path.resolve(__dirname, 'dist');
  7. module.exports = (options = {}) => {
  8. return {
  9. entry: [
  10. path.resolve(srcPath, 'entry.js')
  11. ],
  12. target: 'web',
  13. output: {
  14. path: options.outputPath || distPath,
  15. filename: 'index.js',
  16. libraryTarget: 'commonjs2',
  17. library: pkg.name
  18. },
  19. resolve: {
  20. extensions: ['.js', '.json', '.jsx', '']
  21. },
  22. externals: [{
  23. react: 'react',
  24. 'react-dom': 'react-dom',
  25. 'prop-types': 'prop-types'
  26. }],
  27. module: {
  28. loaders: [{
  29. test: /\.(js|jsx)$/,
  30. include: srcPath,
  31. loader: 'babel',
  32. query: {
  33. cacheDirectory: true
  34. }
  35. }, {
  36. test: /\.svg$/,
  37. loader: 'babel!react-svg'
  38. }, {
  39. test: /\.css$/,
  40. include: srcPath,
  41. loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=rh5v-[name]_[local]&-autoprefixer!postcss')
  42. }, {
  43. test: /\.(eot|ttf|woff|woff2)(\?.*)?$/,
  44. loader: 'url'
  45. }]
  46. },
  47. plugins: [
  48. new ExtractTextPlugin('styles.css'),
  49. new CaseSensitivePathsPlugin()
  50. ]
  51. };
  52. };