helpers.js 882 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import fs from 'fs';
  2. import path from 'path';
  3. import ExtractTextPlugin from 'extract-text-webpack-plugin';
  4. export function readFileOrEmpty(path) {
  5. try {
  6. return fs.readFileSync(path, 'utf-8');
  7. } catch (e) {
  8. return '';
  9. }
  10. }
  11. export const defaultConfig = {
  12. entry: './index',
  13. module: {
  14. rules: [
  15. {
  16. test: /\.css$/,
  17. use: ExtractTextPlugin.extract({
  18. fallback: { loader: 'style-loader' },
  19. use: {
  20. loader: 'css-loader',
  21. options: { minimize: true }
  22. }
  23. })
  24. },
  25. ],
  26. },
  27. plugins: [],
  28. context: __dirname,
  29. output: {
  30. filename: 'destination.js',
  31. path: path.resolve(__dirname, '../', 'js', 'default-exports')
  32. }
  33. };
  34. export function checkForWebpackErrors({err, stats, done}) {
  35. if (err) return done(err);
  36. if (stats.hasErrors()) return done(new Error(stats.toString()));
  37. }