-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
112 lines (108 loc) · 3.66 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const SpritesmithPlugin = require('webpack-spritesmith');
module.exports = {
entry: [
'./src/client/js/app/Bootstrapper.js',
],
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
title: 'Vaults of Git’recht',
favicon: './src/client/images/favicon.ico'
}),
new webpack.ProvidePlugin({
Random: 'random-js'
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new SpritesmithPlugin({
src: {
cwd: path.resolve(__dirname, 'src', 'client', 'images', 'small'),
glob: '*.png'
},
target: {
image: path.resolve(__dirname, 'dist', 'images', 'spritesheet.png'),
css: [
path.resolve(__dirname, 'dist', 'images', 'sprites.css'),
[path.resolve(__dirname, 'dist', 'images', 'spritesheet.json'), {
format: 'pixi_template'
}]
]
},
apiOptions: {
cssImageRef: 'spritesheet.png'
},
spritesmithOptions: {
padding: 2
},
customTemplates: {
pixi_template: function(data) {
const json = {
frames: data.sprites.reduce(function(obj, item) {
obj[item.name] = {
frame: {
x: item.x,
y: item.y,
w: item.width,
h: item.height
},
rotated: false,
trimmed: false,
spriteSourceSize: {x: item.x, y: item.y, w: item.w, h: item.h},
sourceSize: {w: item.w, h: item.h}
};
return obj;
}, {}),
meta: {
app: 'spritesheet-templates',
//"version": "10.2.1",
image: 'spritesheet.png',
scale: 1,
size: {
w: data.spritesheet.width,
h: data.spritesheet.height
}
}
};
return JSON.stringify(json, null, 4);
}
}
})
],
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: [path.resolve(__dirname, 'src')],
query: {
presets: ['es2015']
}
}, {
test: /\.s?css$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
}, {
loader: 'sass-loader',
}]
}, {
loader: 'url-loader?limit=100000',
test: /\.png$/
}
]
},
// http://stackoverflow.com/questions/35171288/error-cannot-resolve-module-style-loader
resolve: {
extensions: ['.js', '.css'],
modules: [
'node_modules'
]
}
};