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