Asset step & script
This commit is contained in:
parent
8456a3cf6f
commit
fc9fb14498
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue