2019-10-15 10:30:08 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
2019-08-01 04:10:21 -07:00
|
|
|
const path = require('path');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: 'production',
|
|
|
|
entry: './src/index.js',
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
filename: 'index.js',
|
|
|
|
libraryExport: 'default',
|
|
|
|
libraryTarget: 'commonjs2'
|
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
// Don't bundle react or react-dom
|
|
|
|
react: {
|
|
|
|
commonjs: "react",
|
|
|
|
commonjs2: "react",
|
|
|
|
amd: "React",
|
|
|
|
root: "React"
|
|
|
|
},
|
|
|
|
"react-dom": {
|
|
|
|
commonjs: "react-dom",
|
|
|
|
commonjs2: "react-dom",
|
|
|
|
amd: "ReactDOM",
|
|
|
|
root: "ReactDOM"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'index.css',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
"presets": ["@babel/preset-react"],
|
|
|
|
"plugins": ["@babel/plugin-transform-flow-strip-types", "@babel/plugin-proposal-class-properties"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
// you can specify a publicPath here
|
|
|
|
// by default it uses publicPath in webpackOptions.output
|
|
|
|
publicPath: '../',
|
|
|
|
hmr: process.env.NODE_ENV === 'development',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'css-loader',
|
|
|
|
],
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|