-
Notifications
You must be signed in to change notification settings - Fork 13
/
webpack.base.config.js
142 lines (139 loc) · 4.09 KB
/
webpack.base.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
const path = require('path');
const webpack = require('webpack');
const TypeScriptConfigFile = require('./tsconfig.json');
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// From SASS -> CSS, we use the same loaders
// When it comes to theme, we want to use style loader options
// to put styles in body, for base styles, we want them in head
const sharedCssLoaders = [{
loader: 'css-loader',
options: {
localIdentName: '[name]__[local]__[hash:base64:5]',
modules: true,
importLoaders: 1,
sourceMap: false,
}
},
{
loader: 'postcss-loader',
},
{
loader: 'sass-loader',
options: {
includePaths: [
path.join(__dirname, 'src'),
path.join(__dirname, 'src', 'styles'),
path.join(__dirname, 'src', 'styles', 'foundation'),
path.join(__dirname, 'src', 'styles', 'components'),
path.join(__dirname, 'src', 'themes', 'Delicious'),
],
sourceMap: false
}
},
{
loader: 'sass-resources-loader',
options: {
resources: [
// './src/styles/calendar.scss',
'./src/styles/foundation.scss',
'./themes/Delicious/foundation.scss',
'./src/styles/shared.scss',
'./themes/Delicious/shared.scss',
],
},
},
];
module.exports = {
resolveLoader: {
alias: {
"shopify-icons-loader": path.join(__dirname, "./config/webpack/SvgToJsonPlugin.js")
}
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
query: {compact: false},
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
loaders: ['babel-loader?compact=false', 'awesome-typescript-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.scss$/,
use: [
{
loader: 'style-loader',
},
...sharedCssLoaders,
],
exclude: [/node_modules/, /themes/]
},
// Theme styles need to be put in body to override base
{
test: /themes.*\.scss/,
use: [
{
loader: 'style-loader',
options: {
insert: 'body',
},
},
...sharedCssLoaders,
],
exclude: [/node_modules/]
},
{
test: /\.svg$/,
loader: 'shopify-icons-loader',
exclude: path.join(__dirname, 'src/components/DatePicker')
},
{
test: /DatePicker.*\.svg/,
loader: [
{
loader: 'babel-loader',
},
{
loader: 'react-svg-loader',
query: {
jsx: false,
}
}
],
},
{
test: /\.(jpe?g|ico|png|gif)$/i,
loader: [
'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack-loader?bypassOnDebug=false'
]
}
]
},
resolve: {
extensions: [
'.ts', '.tsx', '.js', '.jsx', '.scss'
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
},
}),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.LoaderOptionsPlugin({
debug: true,
})
],
devtool: 'source-map',
mode: 'development',
};