Created
March 24, 2020 03:34
-
-
Save davidtran/8e36b7b6fbd0ad9fa064c3f189956c08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Webpack configuration | |
const TerserPlugin = require('terser-webpack-plugin'); | |
const webpack = require('webpack'); | |
const path = require('path'); | |
const isProduction = process.env.NODE_ENV === 'production'; | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const Visualizer = require('webpack-visualizer-plugin'); | |
module.exports = { | |
mode: isProduction ? 'production' : 'development', | |
entry: './src/lib/components/DatePicker/index.js', | |
output: { | |
filename: 'index.js', | |
path: path.resolve(__dirname, 'dist'), | |
libraryTarget: 'umd', | |
globalObject: 'this' | |
}, | |
externals: { | |
react: 'react', | |
'react-dom': { | |
root: 'ReactDOM', | |
commonjs2: 'react-dom', | |
commonjs: 'react-dom', | |
amd: 'react-dom', | |
umd: 'react-dom', | |
}, | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules|bower_components)/, | |
use: { | |
loader: 'babel-loader', | |
}, | |
}, | |
{ | |
test: /\.(s?)css$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
'css-loader', | |
'sass-loader' | |
], | |
}, | |
{ | |
test: /\.svg$/, | |
use: [ | |
{ | |
loader: "babel-loader" | |
}, | |
{ | |
loader: "react-svg-loader", | |
options: { | |
jsx: true // true outputs JSX tags | |
} | |
} | |
] | |
}, | |
], | |
}, | |
optimization: { | |
minimizer: [new TerserPlugin()], | |
}, | |
plugins: [ | |
new MiniCssExtractPlugin(), | |
new Visualizer({ | |
filename: '../statistics.html' | |
}), | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('production'), | |
}) | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment