@pushword/js-helper 0.0.52 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/encore.js +92 -0
package/package.json
CHANGED
package/src/encore.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const WatchExternalFilesPlugin = require("webpack-watch-files-plugin").default;
|
|
2
|
+
const Encore = require("@symfony/webpack-encore");
|
|
3
|
+
const tailwindcss = require("tailwindcss");
|
|
4
|
+
|
|
5
|
+
function getFilesToWatch() {
|
|
6
|
+
return [
|
|
7
|
+
"./../vendor/pushword/core/src/templates/**/*.html.twig",
|
|
8
|
+
"./../vendor/pushword/core/src/templates/*.html.twig",
|
|
9
|
+
"./../vendor/pushword/conversation/src/templates/*.html.twig",
|
|
10
|
+
"./../vendor/pushword/admin-block-editor/src/templates/page/*.html.twig",
|
|
11
|
+
"./../templates/*.html.twig",
|
|
12
|
+
"./../templates/**/*.html.twig",
|
|
13
|
+
"./../templates/**/**/*.html.twig",
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
function getTailwindConfig(watchFiles = null) {
|
|
17
|
+
if (watchFiles === null) watchFiles = getFilesToWatch();
|
|
18
|
+
var tailwindConfig = require("@pushword/js-helper/src/tailwind.config.js");
|
|
19
|
+
tailwindConfig.content = watchFiles;
|
|
20
|
+
return tailwindConfig;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
getFilesToWatch: getFilesToWatch,
|
|
25
|
+
getTailwindConfig: getTailwindConfig,
|
|
26
|
+
getEncore: function (
|
|
27
|
+
watchFiles = null,
|
|
28
|
+
tailwindConfig = null,
|
|
29
|
+
outputPath = "./../public/assets/",
|
|
30
|
+
publicPath = "/assets",
|
|
31
|
+
manifestKeyPrefix = null,
|
|
32
|
+
filesToCopy = [
|
|
33
|
+
{
|
|
34
|
+
from: "./media/", // todo explain
|
|
35
|
+
to: "[name].[ext]",
|
|
36
|
+
pattern: /svg$/,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
from: "./img/",
|
|
40
|
+
to: "[name].[ext]",
|
|
41
|
+
pattern: /header.jpg$/,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
from: "./favicons",
|
|
45
|
+
to: "[name].[ext]",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
entries = [{ name: "app", file: "./app.js" }],
|
|
49
|
+
styleEntries = [{ name: "style", file: "./app.css" }]
|
|
50
|
+
) {
|
|
51
|
+
if (watchFiles === null) {
|
|
52
|
+
watchFiles = getFilesToWatch();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (tailwindConfig === null) {
|
|
56
|
+
tailwindConfig = getTailwindConfig(watchFiles);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Encore.setOutputPath(outputPath)
|
|
60
|
+
.setPublicPath(publicPath)
|
|
61
|
+
.cleanupOutputBeforeBuild()
|
|
62
|
+
.enableSassLoader()
|
|
63
|
+
.enableSourceMaps(false)
|
|
64
|
+
.enableVersioning(false)
|
|
65
|
+
.addPlugin(
|
|
66
|
+
new WatchExternalFilesPlugin({
|
|
67
|
+
files: watchFiles,
|
|
68
|
+
})
|
|
69
|
+
)
|
|
70
|
+
.enablePostCssLoader((options) => {
|
|
71
|
+
options.postcssOptions = {
|
|
72
|
+
plugins: [require("postcss-import"), tailwindcss(tailwindConfig), require("autoprefixer")],
|
|
73
|
+
};
|
|
74
|
+
})
|
|
75
|
+
.disableSingleRuntimeChunk();
|
|
76
|
+
filesToCopy.forEach(function (toCopy) {
|
|
77
|
+
Encore.copyFiles(toCopy);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (manifestKeyPrefix !== null) Encore.setManifestKeyPrefix(manifestKeyPrefix);
|
|
81
|
+
|
|
82
|
+
entries.forEach(function (entry) {
|
|
83
|
+
Encore.addEntry(entry.name, entry.file);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
styleEntries.forEach(function (entry) {
|
|
87
|
+
Encore.addStyleEntry(entry.name, entry.file);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return Encore;
|
|
91
|
+
},
|
|
92
|
+
};
|