-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
73 lines (70 loc) · 1.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
const path = require('path');
const webpack = require('webpack');
const dotenv = require('dotenv');
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
const glob = require('glob');
module.exports = (env) => {
const env2 = dotenv.config().parsed;
const themePath = path.join(__dirname, 'theme/' + env.THEME + '.js');
console.log(themePath);
const envKeys = Object.keys(env2).reduce((prev, next) => {
prev[`process.env.${next}`] = JSON.stringify(env2[next]);
return prev;
}, {});
return {
mode: 'development',
cache: true,
entry: {
app: './client.js',
},
output: {
path: path.join(__dirname),
publicPath: '/',
filename: 'bundle.js',
chunkFilename: '[chunkhash].js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
// {
// test: /\.svg$/,
// use: [
// {
// loader: 'svg-sprite-loader'
// },
// {
// loader: 'svgo-loader',
// options: {
// plugins: [
// {
// removeAttrs: {
// attrs: 'stroke.*'
// }
// }
// ]
// }
// }
// ],
// include: [
// path.resolve('./assets/icons'),
// ]
// }
]
},
resolve: {
alias: {
Theme: themePath
}
},
plugins: [
new webpack.DefinePlugin(envKeys),
new SpriteLoaderPlugin({
plainSprite: true
})
]
}
}