renderer: simplify set static path in production

This commit is contained in:
leejooy96 committed 2022-07-21 10:45:39 +09:00
1 parent c9560b38f0
commit 89a65c9707
2 files changed
+6 -14

No files matched your search

+1 -1
View File
@@ -105,8 +105,8 @@ export default {
removeAttributeQuotes: true,
removeComments: true
},
isBrowser: false,
isDevelopment: IS_DEV_ENV,
staticPath: path.join(__dirname, '/static').replace(/\\/g, '\\\\'),
nodeModules: IS_DEV_ENV
? path.resolve(__dirname, '../../node_modules')
: false
+5 -13
View File
@@ -3,21 +3,13 @@
<head>
<meta charset="utf-8">
<title>Vutron</title>
<% if (htmlWebpackPlugin.options.nodeModules) { %>
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
<script>
require('module').globalPaths.push('<%= htmlWebpackPlugin.options.nodeModules.replace(/\\/g, '\\\\') %>')
</script>
<% } %>
</head>
<body>
<div id="app"></div>
<!-- Set `__static` path to static files in production -->
<% if (!htmlWebpackPlugin.options.isBrowser && !htmlWebpackPlugin.options.isDevelopment) { %>
<script>
window.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
</script>
<% } %>
<!-- webpack builds are automatically injected -->
</body>
<% if (!htmlWebpackPlugin.options.isDevelopment) { %>
<script>
window.__static = '<%= htmlWebpackPlugin.options.staticPath %>'
</script>
<% } %>
</html>