|
|
|
// Copyright 2020 Thomas Hintz
|
|
|
|
//
|
|
|
|
// This file is part of the Alpha Centauri Farming project.
|
|
|
|
//
|
|
|
|
// The Alpha Centauri Farming project is free software: you can
|
|
|
|
// redistribute it and/or modify it under the terms of the GNU General
|
|
|
|
// Public License as published by the Free Software Foundation, either
|
|
|
|
// version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The Alpha Centauri Farming project is distributed in the hope that
|
|
|
|
// it will be useful, but WITHOUT ANY WARRANTY; without even the
|
|
|
|
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with the Alpha Centauri Farming project. If not, see
|
|
|
|
// <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
|
|
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
|
|
|
const webpack = require("webpack");
|
|
|
|
const autoprefixer = require("autoprefixer");
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
|
|
|
app: './src/main.jsx',
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: '[name].bundle.js',
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
title: 'Alpha Centauri Farming',
|
|
|
|
filename: 'main.html',
|
|
|
|
meta: {viewport: 'width=device-width, initial-scale=1'},
|
|
|
|
}),
|
|
|
|
new FaviconsWebpackPlugin('./assets/img/tractor.svg'),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: '[name].css',
|
|
|
|
chunkFilename: '[id].css',
|
|
|
|
}),
|
|
|
|
new CopyPlugin([
|
|
|
|
{ from: './src/server/', to: './' },
|
|
|
|
{ from: './assets/game/', to: './assets/game/' }
|
|
|
|
]),
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
options: {
|
|
|
|
postcss: [
|
|
|
|
autoprefixer()
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.m?(js|jsx)$/,
|
|
|
|
exclude: /(node_modules|bower_components)/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [['@babel/preset-env', { modules: false }],
|
|
|
|
"@babel/preset-react",],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2|eot|ttf|otf|svg|png)$/,
|
|
|
|
use: [
|
|
|
|
'file-loader',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/i,
|
|
|
|
exclude: /(node_modules|bower_components)/,
|
|
|
|
use: [
|
|
|
|
// Creates `style` nodes from JS strings
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
// Translates CSS into CommonJS
|
|
|
|
'css-loader',
|
|
|
|
'postcss-loader',
|
|
|
|
// Compiles Sass to CSS
|
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|