2020-10-13 23:38:20 +02:00
|
|
|
const webpack = require("webpack")
|
|
|
|
const path = require("path")
|
|
|
|
const CopyPlugin = require("copy-webpack-plugin")
|
|
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
2020-10-08 18:21:27 +02:00
|
|
|
|
2020-10-13 23:38:20 +02:00
|
|
|
const outpath = path.resolve(__dirname, "pack")
|
2020-10-08 18:21:27 +02:00
|
|
|
|
|
|
|
function makeCommonConfig() {
|
|
|
|
const commonConfig = {
|
|
|
|
target: "web",
|
|
|
|
mode: "development",
|
2020-10-20 20:48:22 +02:00
|
|
|
entry: "./index.js",
|
2020-10-08 18:21:27 +02:00
|
|
|
node: {
|
|
|
|
__dirname: false,
|
|
|
|
__filename: false
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: "ts-loader",
|
|
|
|
exclude: [/node_modules/],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
loader: "file-loader",
|
|
|
|
},
|
|
|
|
{
|
2020-10-18 02:46:25 +02:00
|
|
|
test: /\.s[ac]ss$/i,
|
|
|
|
use: [
|
2020-10-20 20:22:57 +02:00
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
'sass-loader',
|
2020-10-18 02:46:25 +02:00
|
|
|
],
|
2020-10-09 14:02:19 +02:00
|
|
|
},
|
|
|
|
{
|
2020-10-08 18:21:27 +02:00
|
|
|
test: /\.(tsx?|js|jsx|html)$/,
|
|
|
|
use: [
|
|
|
|
],
|
|
|
|
exclude: [/node_modules/],
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: [
|
|
|
|
'node_modules',
|
|
|
|
path.resolve(__dirname),
|
|
|
|
],
|
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
2020-10-20 20:48:22 +02:00
|
|
|
{ from: path.resolve(__dirname, "static"), to: "static" },
|
2020-10-08 18:21:27 +02:00
|
|
|
{ from: path.resolve(__dirname, "node_modules/easymde/dist/easymde.min.css"), to: "static" },
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
inject: true,
|
|
|
|
title: "OCTO",
|
2020-10-09 17:10:26 +02:00
|
|
|
chunks: ["main"],
|
2020-10-14 15:25:39 +02:00
|
|
|
template: "html-templates/page.ejs",
|
2020-10-18 02:46:25 +02:00
|
|
|
filename: 'index.html',
|
|
|
|
publicPath: '/'
|
2020-10-08 18:21:27 +02:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
entry: {
|
2020-10-20 20:48:22 +02:00
|
|
|
main: "./src/main.tsx",
|
2020-10-08 18:21:27 +02:00
|
|
|
},
|
|
|
|
output: {
|
2020-10-18 02:46:25 +02:00
|
|
|
filename: "static/[name].js",
|
2020-10-08 18:21:27 +02:00
|
|
|
path: outpath
|
|
|
|
}
|
2020-10-13 23:38:20 +02:00
|
|
|
}
|
2020-10-08 18:21:27 +02:00
|
|
|
|
2020-10-13 23:38:20 +02:00
|
|
|
return commonConfig
|
2020-10-08 18:21:27 +02:00
|
|
|
}
|
|
|
|
|
2020-10-13 23:38:20 +02:00
|
|
|
module.exports = makeCommonConfig
|