This repository was archived by the owner on Apr 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
97 lines (93 loc) · 2.23 KB
/
webpack.config.js
File metadata and controls
97 lines (93 loc) · 2.23 KB
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
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
// Is the current build a development build
const IS_DEV = process.env.NODE_ENV === 'development';
/**
* Webpack Configuration
*/
let config = {
devtool: IS_DEV ? 'cheap-source-map' : false,
entry: [path.resolve(__dirname, 'src/assets/style/index.scss')],
output: {
path: path.resolve(__dirname, 'dist'),
},
stats: {
hash: false,
version: false,
children: false,
chunks: false,
modules: false,
reasons: false,
source: false,
publicPath: false,
},
resolve: {
modules: ['node_modules', path.resolve(__dirname, 'src')],
alias: {
'@src': path.resolve(__dirname, 'src'),
},
},
plugins: [
new ExtractTextPlugin({
filename: 'eccss.css',
allChunks: true,
}),
new FriendlyErrorsWebpackPlugin(),
],
module: {
rules: [
{
enforce: 'pre',
test: /\.(js|s?[ca]ss)$/,
include: path.resolve(__dirname, 'src'),
loader: 'import-glob',
},
{
test: /\.scss/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: IS_DEV,
importLoaders: 2,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: IS_DEV,
},
},
'svg-transform-loader/encode-query',
{
loader: 'sass-loader',
options: {
sourceMap: IS_DEV,
},
},
],
}),
},
{
test: /\.svg$/,
use: [
{
loader: 'file-loader',
options: {
name: 'image/[name]_[hash:8].[ext]',
},
},
{ loader: 'svg-transform-loader' },
],
},
],
},
};
if (!IS_DEV) {
config.plugins.push(new CleanWebpackPlugin([path.resolve(__dirname, 'dist')]));
}
module.exports = config;