59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
// Shared config (dev and prod)
|
|
const {resolve} = require("path");
|
|
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
|
|
const StyleLintPlugin = require("stylelint-webpack-plugin");
|
|
const webpack = require('webpack');
|
|
const Dotenv = require("dotenv-webpack");
|
|
|
|
module.exports = function (env, argv) {
|
|
const config = {};
|
|
config.output = {
|
|
publicPath: "/",
|
|
};
|
|
|
|
config.resolve = {
|
|
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
plugins: [new TsconfigPathsPlugin()]
|
|
};
|
|
config.context = resolve(__dirname, "../../src");
|
|
config.module = {
|
|
rules: [],
|
|
};
|
|
config.module.rules.push({
|
|
test: /\.js$/,
|
|
use: ["babel-loader", "source-map-loader"],
|
|
exclude: /node_modules/
|
|
});
|
|
config.module.rules.push({
|
|
test: /\.tsx?$/,
|
|
use: ["babel-loader", "ts-loader"]
|
|
});
|
|
|
|
config.module.rules.push({
|
|
test: /\.(jpe?g|png|gif|svg)$/i,
|
|
loaders: [
|
|
"file-loader?hash=sha512&digest=hex&name=assets/img/[hash].[ext]",
|
|
"image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false"
|
|
]
|
|
});
|
|
|
|
const envVars = {};
|
|
Object.keys(process.env).forEach((key) => {
|
|
envVars[`process.env.${key}`] = JSON.stringify(process.env[key]);
|
|
});
|
|
|
|
config.plugins = [
|
|
new webpack.DefinePlugin(envVars),
|
|
new StyleLintPlugin(),
|
|
new Dotenv({
|
|
path: "./.env"
|
|
}),
|
|
];
|
|
|
|
config.performance = {
|
|
hints: false
|
|
};
|
|
|
|
return config;
|
|
};
|