Switch to vite

This commit is contained in:
Alexander Yakovlev 2024-01-16 20:11:09 +06:00
parent 4610b6f863
commit 23514ee118
8 changed files with 990 additions and 2844 deletions

View file

@ -1,7 +1,7 @@
{
"sourceType": "module",
"presets": [
"@babel/preset-flow",
"@babel/preset-env"
"@babel/preset-flow"
],
"plugins": [
"babel-plugin-transform-flow-enums"

View file

@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>Chernava</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="main.css" />
<link rel="stylesheet" href="scss/style.scss" />
</head>
<body id="body">
<div id="page" class="container">
@ -65,8 +65,7 @@
</div>
</div>
<!-- CDN JS Libraries -->
<script src="main.js"></script>
<script src="src/index.js" type="module"></script>
</body>
</html>

View file

@ -1,43 +1,33 @@
{
"type": "module",
"scripts": {
"publish": "zip -r build build && butler push build.zip oreolek/pretty-soldier-of-the-night:default",
"build": "webpack --config ./webpack.config.js",
"start": "webpack-dev-server --content-base public/ --inline --port 3001",
"prod": "./node_modules/cross-env/src/bin/cross-env.js NODE_ENV=production ./node_modules/webpack/bin/webpack.js --mode=production",
"dev": "./node_modules/cross-env/src/bin/cross-env.js NODE_ENV=development ./node_modules/webpack/bin/webpack.js",
"watch": "./node_modules/webpack/bin/webpack.js --watch"
"publish": "zip -r build build && butler push build.zip oreolek/game-slug:default",
"build": "vite build",
"start": "vite preview",
"prod": "vite build",
"dev": "vite",
"watch": "vite preview"
},
"dependencies": {
"@babel/preset-env": "^7.22.20",
"@svgdotjs/svg.js": "^3.2.0",
"@types/loader-utils": "^2.0.4",
"@types/loader-utils": "^2.0.6",
"autoprefixer": "^10.4.16",
"babel-loader": "^9.1.3",
"bootstrap": "^5.3.2",
"browser-sync": "^2.29.3",
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^7.0.3",
"css-loader": "^6.8.1",
"flow-enums-runtime": "^0.0.6",
"inkjs": "^2.2.2",
"inklecate-loader": "^1.8.0",
"jquery": "^3.7.1",
"loader-utils": "^3.2.1",
"mini-css-extract-plugin": "^2.7.6",
"postcss": "^8.4.30",
"postcss-loader": "^7.3.3",
"sass": "^1.68.0",
"sass-loader": "^12.6.0",
"schema-utils": "^4.2.0",
"webpack": "^5.88.2",
"webpack-cli": "^4.10.0"
"postcss": "^8.4.33",
"sass": "^1.69.7",
"schema-utils": "^4.2.0"
},
"devDependencies": {
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.0",
"@babel/preset-flow": "^7.22.15",
"@types/jquery": "^3.5.19",
"@babel/preset-flow": "^7.23.3",
"@types/jquery": "^3.5.29",
"babel-plugin-transform-flow-enums": "^0.0.2",
"eslint-plugin-fb-flow": "^0.0.4"
"babel-preset-vite": "^1.1.2",
"eslint-plugin-fb-flow": "^0.0.4",
"vite": "^5.0.11",
"vite-plugin-babel": "^1.2.0",
"vite-plugin-ink": "^0.1.2"
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,5 +0,0 @@
module.exports = {
plugins: {
'autoprefixer': {}
}
}

View file

@ -1,12 +1,10 @@
/* @flow */
import * as jQuery from "jquery";
const inkjs = require('inkjs').Story;
/**
* Path to your game's compiled JSON.
* It is relative to index.html file.
* Path to your game's main ink file relative to this file.
*/
const entryPoint = require('../game/game.ink');
import entryPoint from '../game/game.ink';
/**
* You can change this function.
@ -196,7 +194,6 @@ function loadGame (s: any) {
return results;
};
const data = entryPoint.storyContent;
const progress = localStorage.getItem("progress");
if (progress != null) {
window['progress'] = JSON.parse(progress);
@ -204,7 +201,7 @@ if (progress != null) {
window['progress_steps'] = 0;
window['progress'] = [];
}
window['s'] = new inkjs(data)
window['s'] = entryPoint
window['s'].onError = function(error){
alert(error);
};

22
vite.config.js Normal file
View file

@ -0,0 +1,22 @@
import { defineConfig } from "vite";
import { ink } from "vite-plugin-ink";
import autoprefixer from 'autoprefixer';
import babel from 'vite-plugin-babel';
export default defineConfig({
plugins: [
babel(),
ink()
],
presets: ["babel-preset-vite"],
css: {
postcss: {
plugins: [
autoprefixer({}),
],
},
},
build: {
outDir: 'build',
},
});

View file

@ -1,60 +0,0 @@
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry: [
'./src/index.js',
'./scss/style.scss'
],
plugins: [
new MiniCssExtractPlugin(),
new CopyPlugin({
patterns: [
{ from: './html/', to: '' },
//{ from: './images/', to: 'images' },
],
}),
],
devtool: process.env.NODE_ENV === 'production' ? false : 'inline-source-map',
performance: {
maxEntrypointSize: 900000,
maxAssetSize: 900000
},
module: {
rules: [
{
test: /\.ink$/,
use: require.resolve('inklecate-loader'),
},
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
}
},
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
// Translates CSS into CommonJS
'css-loader',
'postcss-loader',
// Compiles Sass to CSS
'sass-loader'
]
},
]
},
output: {
path: path.resolve(__dirname, 'build')
},
watchOptions: {
// for some systems, watching many files can result in a lot of CPU or memory usage
// https://webpack.js.org/configuration/watch/#watchoptionsignored
// don't use this pattern, if you have a monorepo with linked packages
ignored: /node_modules/,
},
}