Optimize webpack usage

Signed-off-by: Egor Savkin <es@m-labs.hk>
pull/77/head
Egor Savkin 2023-07-12 13:16:44 +08:00
parent ddd49b71af
commit 053d31ddce
7 changed files with 6 additions and 2200 deletions

View File

@ -18,9 +18,8 @@ Start:
zola serve
```
To update the .min.js, .bundle.js and .jsx file:
To update the .bundle.js and .jsx file:
```
nix-shell -p nodejs --run "npm run build"
nix-shell -p nodejs --run "npx webpack"
```

View File

@ -4,8 +4,8 @@
"description": "These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. For deployment, see the nix-scripts repository. Commits to https://git.m-labs.hk/M-Labs/web2019.git are automatically deployed to m-labs.hk through Hydra.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "./node_modules/.bin/babel static/js/shop.jsx --watch -o static/js/shop_bundle.js",
"build": "./node_modules/.bin/babel static/js/shop.jsx -o static/js/shop.min.js"
"start": "npx webpack --watch",
"build": "npx webpack"
},
"repository": {
"type": "git",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2191
static/js/shop.min.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,6 @@
<!-- Load our React component. -->
<!-- <script type="text/babel" src="{{ get_url(path='js/shop.jsx', cachebust=true) }}"></script> -->
<!-- <script src="{{ get_url(path='js/shop.min.js', cachebust=true) }}"></script> -->
<script src="{{ get_url(path='js/shop.bundle.js', cachebust=true) }}"></script>
{% endblock %}

View File

@ -2,7 +2,7 @@ const path = require('path');
module.exports = {
entry: {
shop: './static/js/shop.min.js'
shop: './static/js/shop.jsx'
},
output: {
path: path.resolve(__dirname, './static/js'),
@ -11,7 +11,7 @@ module.exports = {
module: {
rules: [
{
test: /\.js$/,
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: 'babel-loader'
}