69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
var path = require("path"),
|
|
webpack = require("webpack"),
|
|
MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
var isProduction =
|
|
process.argv.indexOf("-p") >= 0 || process.env.NODE_ENV === "production";
|
|
var sourcePath = path.join(__dirname, ".");
|
|
|
|
var commonConfig = {
|
|
context: sourcePath,
|
|
target: "web",
|
|
mode: isProduction ? "production" : "development",
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.tsx?$/,
|
|
exclude: [/node_modules/, /_Development/],
|
|
use: {
|
|
loader: "ts-loader",
|
|
},
|
|
},
|
|
{
|
|
test: /.jsx?$/,
|
|
exclude: [/node_modules/, /_Development/],
|
|
use: {
|
|
loader: "babel-loader",
|
|
options: {
|
|
presets: ["@babel/preset-env", "@babel/preset-react"],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
test: /\.(sa|sc|c)ss$/,
|
|
use: [
|
|
!isProduction ? "style-loader" : MiniCssExtractPlugin.loader,
|
|
"css-loader",
|
|
"postcss-loader",
|
|
"sass-loader",
|
|
],
|
|
},
|
|
{
|
|
test: /\.(jpe?g|png|gif|svg)$/,
|
|
loader: "file-loader",
|
|
},
|
|
],
|
|
},
|
|
externals: {
|
|
jquery: "jQuery",
|
|
},
|
|
plugins: [
|
|
new webpack.EnvironmentPlugin({
|
|
NODE_ENV: "development", // use 'development' unless process.env.NODE_ENV is defined
|
|
DEBUG: false,
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
$: "jquery",
|
|
jQuery: "jquery",
|
|
"window.jQuery": "jquery",
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
// Options similar to the same options in webpackOptions.output
|
|
// both options are optional
|
|
filename: "../module.css",
|
|
chunkFilename: "[id].css",
|
|
}),
|
|
],
|
|
};
|
|
|
|
module.exports = commonConfig; |