const path = require('path'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const pkg = require('./package.json'); const srcPath = path.resolve(__dirname, 'src'); const distPath = path.resolve(__dirname, 'dist'); module.exports = (options = {}) => { return { entry: [ path.resolve(srcPath, 'entry.js') ], target: 'web', output: { path: options.outputPath || distPath, filename: 'index.js', libraryTarget: 'commonjs2', library: pkg.name }, resolve: { extensions: ['.js', '.json', '.jsx', ''] }, externals: [{ react: 'react', 'react-dom': 'react-dom', 'prop-types': 'prop-types' }], module: { loaders: [{ test: /\.(js|jsx)$/, include: srcPath, loader: 'babel', query: { cacheDirectory: true } }, { test: /\.svg$/, loader: 'babel!react-svg' }, { test: /\.css$/, include: srcPath, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=rh5v-[name]_[local]&-autoprefixer!postcss') }, { test: /\.(eot|ttf|woff|woff2)(\?.*)?$/, loader: 'url' }] }, plugins: [ new ExtractTextPlugin('styles.css'), new CaseSensitivePathsPlugin() ] }; };