-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
executable file
·178 lines (174 loc) · 6.79 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* eslint-disable global-require */
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path');
const ExtractTextPlugin = require('sgmf-scripts')['extract-text-webpack-plugin'];
const sgmfScripts = require('sgmf-scripts');
const webpack = require('webpack');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const cartridgeFolderName = 'int_sequra_sfra';
const CleanWebpackPlugin = require('clean-webpack-plugin');
const bootstrapFunctionality = {
Alert: 'exports-loader?Alert!bootstrap/js/src/alert',
Carousel: 'exports-loader?Carousel!bootstrap/js/src/carousel',
Collapse: 'exports-loader?Collapse!bootstrap/js/src/collapse',
Modal: 'exports-loader?Modal!bootstrap/js/src/modal',
Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/src/scrollspy',
Tab: 'exports-loader?Tab!bootstrap/js/src/tab',
Util: 'exports-loader?Util!bootstrap/js/src/util',
Select: 'exports-loader?Util!bootstrap-select/js/dist/select',
/** Remove these comments if u wanna any of these bootstrap funcitonalities */
// Dropdown: 'exports-loader?Dropdown!bootstrap/js/src/dropdown',
// Popover: 'exports-loader?Popover!bootstrap/js/src/popover',
// Tooltip: 'exports-loader?Tooltip!bootstrap/js/src/tooltip',
// Button: 'exports-loader?Button!bootstrap/js/src/button',
};
module.exports = [
{
mode: process.env.NODE_ENV,
devtool: process.env.NODE_ENV === 'production' ? 'none' : 'source-maps',
name: 'js',
entry: sgmfScripts.createJsPath(),
output: {
path: path.resolve(`./cartridges/${cartridgeFolderName}/cartridge/static`),
filename: '[name].js',
},
plugins: [
new CleanWebpackPlugin(
[
'./cartridges/int_sequra_sfra/cartridge/static/default/js',
],
{
verbose: true,
dry: false,
root: path.join(__dirname, ''),
beforeEmit: false,
},
),
new webpack.ProvidePlugin(bootstrapFunctionality),
],
resolve: {
alias: {
jquery: path.resolve(
__dirname,
'../storefront-reference-architecture/node_modules/jquery',
),
bootstrap: path.resolve(__dirname, '../link_sequra/node_modules/bootstrap'),
lodash: path.resolve(
__dirname,
'../storefront-reference-architecture/node_modules/lodash',
),
},
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/env',
{
targets: {
node: '8.10',
},
},
],
],
plugins: [
[
'@babel/plugin-proposal-object-rest-spread',
{ loose: true, useBuiltIns: true },
],
],
cacheDirectory: true,
sourceType: 'unambiguous',
},
},
},
{
test: /bootstrap(.)*\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/env'],
plugins: ['@babel/plugin-proposal-object-rest-spread'],
cacheDirectory: true,
},
},
},
],
},
},
{
mode: 'none',
name: 'scss',
entry: sgmfScripts.createScssPath(),
devtool: 'source-map',
output: {
path: path.resolve(`./cartridges/${cartridgeFolderName}/cartridge/static`),
filename: '[name].css',
},
module: {
unknownContextCritical: false,
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
url: false,
sourceMap: true,
},
},
'postcss-loader',
{
loader: 'postcss-loader',
options: {
plugins: [require('autoprefixer')()],
},
},
{
loader: 'sass-loader',
options: {
includePaths: [
path.resolve(
process.cwd(),
'../storefront-reference-architecture/node_modules/',
),
path.resolve(
process.cwd(), // eslint-disable-next-line max-len
'../storefront-reference-architecture/node_modules/flag-icon-css/sass',
),
],
sourceMap: true,
},
},
],
}),
},
],
},
plugins: [
new ExtractTextPlugin({
filename: '[name].css',
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new StyleLintPlugin({
configFile: `./cartridges/${cartridgeFolderName}/cartridge/client/default/scss/.stylelintrc.json`,
failOnError: true,
}),
],
externals: {
base: '../storefront-reference-architecture/cartridges/app_storefront_base/',
jquery: 'jQuery',
},
},
];