helpers.js 841 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. }
  22. })
  23. }
  24. ]
  25. },
  26. plugins: [],
  27. context: __dirname,
  28. output: {
  29. filename: "destination.js",
  30. path: path.resolve(__dirname, "../", "js", "default-exports")
  31. }
  32. };
  33. export function checkForWebpackErrors({ err, stats, done }) {
  34. if (err) return done(err);
  35. if (stats.hasErrors()) return done(new Error(stats.toString()));
  36. }