Skip to content

Instantly share code, notes, and snippets.

@chrispcode
Created January 16, 2019 09:09
Show Gist options
  • Save chrispcode/7ce14e347de142585566eb1d1548a867 to your computer and use it in GitHub Desktop.
Save chrispcode/7ce14e347de142585566eb1d1548a867 to your computer and use it in GitHub Desktop.
Component library Webpack
const path = require('path');
const webpack = require('webpack');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const port = 8000;
module.exports = {
mode: 'production',
resolve: {
alias: {
react: path.resolve('./node_modules/react')
},
extensions: ['.ts', '.tsx', '.js', '.json']
},
entry: {
index: ['@babel/polyfill', './src/index'],
},
devtool: 'source-map',
output: {
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
library: '@storebrand/react',
libraryTarget: 'umd'
},
externals: ['canvas'],
module: {
rules: [
{
test: /\.(tsx?)|(jsx?)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
extends: path.join(__dirname, '.babelrc')
}
},
{
loader: 'react-hot-loader/webpack'
},
]
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
modules: true
}
}
]
},
{
test: /\.(png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 8192,
mimetype: 'image/png',
name: 'images/[name].[ext]',
}
}
},
{
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
},
]
},
plugins: []
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment