-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
60 lines (58 loc) · 1.57 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
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const pug = require('pug');
const webpack = require('webpack');
const sourcePath = path.join(__dirname, 'infokala', 'static_src');
const staticsPath = path.join(__dirname, 'infokala', 'static', 'infokala');
module.exports = function (env, argv) {
const isProd = !!env.production;
return {
devtool: isProd ? 'source-map' : 'eval',
context: sourcePath,
entry: {
infokala: 'infokala/infokala.js',
},
output: {
path: staticsPath,
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.stylus/,
use: ['style-loader', 'css-loader', 'stylus-loader'],
},
{
test: /\.(woff|ttf|eot|svg|png|jpeg)/,
use: ['url-loader?name=[name].[hash:6].[ext]&limit=10000'],
},
],
},
resolve: {
extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js'],
modules: [path.resolve(__dirname, 'node_modules'), sourcePath],
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: 'infokala/infokala.pug',
to: 'infokala.html',
transform: (content, path) => {
return pug.render(content, { compileDebug: !isProd }, path);
},
},
],
}),
],
};
};