mirror of
https://github.com/chaoticbackup/chaoticbackup.github.io.git
synced 2026-03-22 01:34:20 -05:00
93 lines
2.0 KiB
JavaScript
93 lines
2.0 KiB
JavaScript
const path = require('path');
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
const webpack = require('webpack');
|
|
require("@babel/register");
|
|
|
|
const devMode = (process.env.NODE_ENV !== 'production' && process.argv.indexOf('-p') === -1);
|
|
|
|
const config = {
|
|
entry: ["@babel/polyfill", `${__dirname}/src/components/index.js`],
|
|
|
|
output: {
|
|
path: `${__dirname}/build`,
|
|
publicPath: '/build/',
|
|
filename: 'bundle.js',
|
|
},
|
|
|
|
optimization: {
|
|
splitChunks: {
|
|
cacheGroups: {
|
|
styles: {
|
|
name: 'styles',
|
|
test: /\.css$/,
|
|
chunks: 'all',
|
|
enforce: true
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.(js|jsx)$/,
|
|
exclude: /node_modules/,
|
|
loader: 'babel-loader',
|
|
options: {
|
|
"presets": [
|
|
"@babel/preset-env",
|
|
"@babel/preset-react",
|
|
"@babel/preset-flow",
|
|
],
|
|
"plugins": [
|
|
"@babel/plugin-transform-runtime",
|
|
["@babel/plugin-proposal-decorators", {"legacy": true }],
|
|
["@babel/plugin-proposal-class-properties", { "loose": true }]
|
|
]
|
|
}
|
|
},
|
|
{
|
|
test: /\.s?[ac]ss$/,
|
|
use: [
|
|
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
|
|
'css-loader',
|
|
'sass-loader',
|
|
],
|
|
}
|
|
]
|
|
},
|
|
|
|
resolve: {
|
|
extensions: ['.js', '.jsx'],
|
|
},
|
|
|
|
node: {
|
|
fs: 'empty',
|
|
},
|
|
|
|
// First array is dev only, second is production
|
|
plugins: devMode ? [
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].css',
|
|
chunkFilename: '[id].css',
|
|
})
|
|
] : [
|
|
new webpack.DefinePlugin({
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
}),
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
output: {
|
|
comments: false,
|
|
},
|
|
warnings: true,
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].[hash].css',
|
|
chunkFilename: '[id].[hash].css',
|
|
})
|
|
],
|
|
};
|
|
|
|
// Exports
|
|
module.exports = config;
|