Skip to content

Commit

Permalink
refa: raw NJK includes
Browse files Browse the repository at this point in the history
  • Loading branch information
Myllaume committed Oct 14, 2024
1 parent e139d98 commit 5a9f4ba
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
6 changes: 6 additions & 0 deletions core/models/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { fileURLToPath } from 'url';
import convertWikilinks from '../utils/convertWikilinks.js';
import convertQuotes from '../utils/convertQuotes.js';
import cosmoscopeTemplate from '../../static/template/cosmoscope.njk';
import favicon from '../../static/icons/cosmafavicon.png';
import logo from '../../static/icons/cosmalogo.svg';
import frontendScript from 'front';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -319,6 +322,9 @@ class Template {
},

app: app, // app version, description, license…
script: frontendScript,
favicon,
logo,
});
}
}
Expand Down
16 changes: 3 additions & 13 deletions static/template/cosmoscope.njk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="date" content="{{ date }}">
<title>Cosma — {{ metadata.title }}</title>

<link rel="icon" type="image/png" sizes="16x16" href="{{ faviconPath | imgPathToBase64 }}" />
<link rel="icon" type="image/png" sizes="16x16" href="{{ favicon }}" />

<style>
:root {
Expand Down Expand Up @@ -534,9 +534,7 @@
{% endif %}

{% if publishMode and metadata %}
<div class="logo">
{% include "static/icons/cosmalogo.svg" %}
</div>
<div class="logo">{{ logo | safe }}</div>
{% else %}
<h1>Cosma</h1>
{% endif %}
Expand Down Expand Up @@ -597,17 +595,9 @@
const sorting = {{ sorting | dump | safe }};
const focusIsActive = {{ focusIsActive }};
</script>
{# Cosma functions #}

{% if devMode %}
<script src="dist/front.js"></script>
{% else %}
<script>
{% include "dist/front.js" %}
{{ script | safe }}
</script>
{% endif %}

</body>

Expand Down
16 changes: 16 additions & 0 deletions webpack-back.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ export default {
test: /\.njk$/,
type: 'asset/source',
},
{
test: /\.raw.js$/,
type: 'asset/source',
},
{
test: /\.svg$/,
type: 'asset/source',
},
{
test: /\.png$/,
type: 'asset/inline',
},
],
},
plugins: [
Expand All @@ -31,6 +43,10 @@ export default {
],
resolve: {
extensions: ['.js'],
alias: {

front: path.resolve(__dirname, './dist/front.raw.js'), // Chemin vers le bundle front
},
},
mode: 'development',
};
2 changes: 1 addition & 1 deletion webpack-front.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
entry: path.resolve(__dirname, './core/frontend/index.js'),
output: {
path: path.resolve(__dirname, './dist'),
filename: 'front.js',
filename: 'front.raw.js',
},
module: {
rules: [
Expand Down

0 comments on commit 5a9f4ba

Please sign in to comment.