diff --git a/lib/createConfig.js b/lib/createConfig.js index d2ab0fa..b85e32d 100644 --- a/lib/createConfig.js +++ b/lib/createConfig.js @@ -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'] diff --git a/specs/createConfig.spec.js b/specs/createConfig.spec.js index dcb4e3f..f14348b 100644 --- a/specs/createConfig.spec.js +++ b/specs/createConfig.spec.js @@ -2,7 +2,6 @@ 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'; @@ -10,13 +9,7 @@ test('createConfig', (t) => { 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: { @@ -37,11 +30,6 @@ test('createConfig', (t) => { path: path.join(cacheDir, '/[name].manifest.json'), name: '[name]_[hash]' } - }, - { - options: { - compress: true, - } } ] }; diff --git a/specs/pluginSupport.spec.js b/specs/pluginSupport.spec.js new file mode 100644 index 0000000..8abc2d9 --- /dev/null +++ b/specs/pluginSupport.spec.js @@ -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(); +}); diff --git a/src/createConfig.js b/src/createConfig.js index 96bfc37..0094e95 100644 --- a/src/createConfig.js +++ b/src/createConfig.js @@ -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']