-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
119 lines (115 loc) · 2.88 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
113
114
115
116
117
118
119
/* eslint-env node */
const path = require('path');
const webpack = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const isDebug = process.argv.includes('--debug');
const ExtractChokhmahCSS = new ExtractTextPlugin({
filename: 'chokhmah.css',
});
const config = {
context: path.resolve(__dirname),
devServer: {
contentBase: `${__dirname}/dist`,
hot: true,
},
devtool: 'source-map',
entry: './components/index.js',
externals: ['lodash', 'moment', 'react', 'react-dom'],
module: {
rules: [
{
enforce: 'pre',
include: [
path.resolve(__dirname, 'components'),
path.resolve(__dirname, 'utils'),
],
loader: 'eslint-loader',
},
{
test: /\.(js|jsx)$/,
include: [
path.resolve(__dirname, 'components'),
path.resolve(__dirname, 'utils'),
path.resolve(__dirname, 'icons'),
],
loader: 'babel-loader',
},
{
test: /\.scss$/,
include: [
path.resolve(__dirname, 'scss'),
],
loader: ExtractChokhmahCSS.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: isDebug,
minimize: !isDebug,
},
},
'resolve-url-loader',
{
loader: 'postcss-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
}),
},
// node_modules css
{
test: /\.css/,
include: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, '../../node_modules'),
],
loader: ExtractChokhmahCSS.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: isDebug,
minimize: !isDebug,
},
},
],
}),
},
],
},
output: {
filename: 'index.js',
chunkFilename: '[id].js',
library: 'chokhmah',
libraryTarget: 'umd',
path: `${__dirname}/dist`,
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
ExtractChokhmahCSS,
new StyleLintPlugin({
failOnError: !isDebug,
files: ['scss/**/*.scss'],
quiet: false,
}),
new webpack.NamedModulesPlugin(),
// new webpack.HotModuleReplacementPlugin(),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
}),
],
};
module.exports = config;