summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarudor <marudor@marudor.de>2018-09-10 19:53:19 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-10 22:49:50 +0200
commitfc9fb14498cf466083ba84c9d769dfd4cf296a83 (patch)
treeb7f57d4630c91b0d1ba754326300683ead1fc702
parent8456a3cf6fcd2588c68ef39ad04b6c0a233d3f5d (diff)
Asset step & script
-rw-r--r--package.json8
-rw-r--r--scripts/copyAssets.js25
-rw-r--r--webpack.config.js7
3 files changed, 32 insertions, 8 deletions
diff --git a/package.json b/package.json
index ddd8ef8b..d671bda6 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,10 @@
"author": "marudor <marudor@marudor.de>",
"license": "MIT",
"scripts": {
- "build": "NODE_ENV=production webpack",
+ "build": "npm run -s build:clean && NODE_ENV=production run-p build:assets build:webpack",
+ "build:clean": "rimraf public/assets",
+ "build:assets": "node scripts/copyAssets.js",
+ "build:webpack": "webpack",
"build:watch": "webpack --watch"
},
"dependencies": {
@@ -29,6 +32,9 @@
"imports-loader": "^0.8.0",
"less": "^3.0.2",
"less-loader": "^4.0.5",
+ "mkdirp": "^0.5.1",
+ "npm-run-all": "^4.1.3",
+ "rimraf": "^2.6.2",
"style-loader": "^0.21.0",
"webpack": "^3"
}
diff --git a/scripts/copyAssets.js b/scripts/copyAssets.js
new file mode 100644
index 00000000..3c425baa
--- /dev/null
+++ b/scripts/copyAssets.js
@@ -0,0 +1,25 @@
+const fs = require("fs");
+const path = require("path");
+const mkdirp = require("mkdirp");
+
+const baseAssetPath = {
+ src: path.resolve("resources/assets"),
+ target: path.resolve("public/assets")
+};
+
+const emojiPath = {
+ src: baseAssetPath.src + "/emojis",
+ target: baseAssetPath.target + "/emojis"
+};
+
+mkdirp.sync(emojiPath.target);
+
+const emojis = fs.readdirSync(emojiPath.src);
+
+emojis.forEach(e => {
+ fs.copyFile(`${emojiPath.src}/${e}`, `${emojiPath.target}/${e}`, e => {
+ if (e) {
+ console.error(e);
+ }
+ });
+});
diff --git a/webpack.config.js b/webpack.config.js
index fd36b0f9..261c1c44 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -23,11 +23,6 @@ for (let i = 0; i < 7; i++) {
themeEntries[`theme${i}`] = `./resources/assets/themes/theme${i}.less`;
}
-const emojis = {};
-for (let emoji of ['redface', 'wind', 'smile', 'sad', 'lol', 'cry', 'rolleyes', 'evil', 'mad', 'question']){
- emojis[`${emoji}`] = `./resources/assets/emojis/${emoji}.gif`;
-}
-
module.exports = {
context: __dirname,
resolve: {
@@ -36,7 +31,6 @@ module.exports = {
entry: {
...themeEntries,
vendor: './resources/assets/js/vendor.js',
- ...emojis,
},
output: {
path: path.resolve('public/assets'),
@@ -52,7 +46,6 @@ module.exports = {
query: { cacheDirectory: true },
},
{ test: /\.(eot|ttf|otf|svg|woff2?)(\?.*)?$/, loader: 'file-loader' },
- { test: /\.gif$/, loader: 'file-loader?name=emojis/[name].[ext]' },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.less$/, use: ExtractTextPlugin.extract({