You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
841 B

4 years ago
  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. }