Skip to content

Commit

Permalink
Don't use default params
Browse files Browse the repository at this point in the history
  • Loading branch information
drewhamlett committed Jul 2, 2017
1 parent 57c1138 commit f530359
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 15 deletions.
4 changes: 3 additions & 1 deletion lib/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ var _paths = require('./paths');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const createConfig = ({ filename, entry, plugins = [] }) => {
const createConfig = ({ filename, entry, plugins }) => {
plugins = plugins || [];

return {
resolve: {
extensions: ['.js', '.jsx']
Expand Down
14 changes: 1 addition & 13 deletions specs/createConfig.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ import test from 'tape';
import createConfig from '../src/createConfig';
import { cacheDir } from '../src/paths';
import path from 'path';
import webpack from 'webpack';

test('createConfig', (t) => {
const filename = '[name].[hash].js';
const entry = {
vendor: ['react', 'react-dom']
};

const plugins = [
new webpack.optimize.UglifyJsPlugin({
compress: true,
}),
];

const results = createConfig({ filename, entry, plugins });
const results = createConfig({ filename, entry });

const expected = {
resolve: {
Expand All @@ -37,11 +30,6 @@ test('createConfig', (t) => {
path: path.join(cacheDir, '/[name].manifest.json'),
name: '[name]_[hash]'
}
},
{
options: {
compress: true,
}
}
]
};
Expand Down
51 changes: 51 additions & 0 deletions specs/pluginSupport.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import test from 'tape';
import createConfig from '../src/createConfig';
import { cacheDir } from '../src/paths';
import path from 'path';
import webpack from 'webpack';

test('pluginSupport', (t) => {
const filename = '[name].[hash].js';
const entry = {
vendor: ['react', 'react-dom']
};

const plugins = [
new webpack.optimize.UglifyJsPlugin({
compress: true,
}),
];

const results = createConfig({ filename, entry, plugins });

const expected = {
resolve: {
extensions: [
'.js',
'.jsx'
]
},
entry: entry,
output: {
path: path.join(cacheDir, '/bundles'),
filename: filename,
library: '[name]_[hash]'
},
plugins: [
{
options: {
path: path.join(cacheDir, '/[name].manifest.json'),
name: '[name]_[hash]'
}
},
{
options: {
compress: true,
}
}
]
};

t.deepEqual(results, expected, 'should out config currently with plugins');
t.end();
});
4 changes: 3 additions & 1 deletion src/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import webpack from 'webpack';
import path from 'path';
import { cacheDir } from './paths';

const createConfig = ({ filename, entry, plugins = [] }) => {
const createConfig = ({ filename, entry, plugins }) => {
plugins = plugins || [];

return {
resolve: {
extensions: ['.js', '.jsx']
Expand Down

0 comments on commit f530359

Please sign in to comment.