This repository has been archived by the owner on Apr 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
127 lines (111 loc) · 2.73 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
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const PRODUCTION_MODE = process.env.NODE_ENV === 'production'
module.exports = {
/**
* Webpack entry points: add files to this array if you'd like them to be
* compiled and copied to the build folder using the modules in this
* configuration file
*/
entry: {
app: [
'./resources/js/app.js',
'./resources/scss/app.scss'
]
},
/**
* Webpack output configuration: be sure to update this path if you decide to
* rename your theme directory
*/
output: {
path: path.resolve(__dirname, '_catalogs/masterpage/bones/js'),
filename: '[name].js'
},
/**
* Use source-map to create source maps during development builds
*/
devtool: PRODUCTION_MODE ? false : 'source-map',
/**
* Webpack module configuration
*/
module: {
rules: [
/**
* Compile Sass stylesheets to CSS using sass-loader and css-loader
*/
{
test: /\.s[ac]ss$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
sourceMap: !PRODUCTION_MODE
}
},
{
loader: 'sass-loader',
options: {
sourceMap: !PRODUCTION_MODE
}
}
]
})
},
/**
* Copy font files to the build folder using file-loader; by default,
* fonts must be within a folder named "fonts" to be properly recognized
* by the test regular expression
*/
{
test: /fonts\/.*\.(eot|ttf|woff2?|svg)([\?#].*)?$/,
loader: 'file-loader',
options: {
name: '../fonts/[name].[ext]'
}
},
/**
* Copy images to the build folder using file-loader
*/
{
test: /\.(png|jpe?g|gif|ico|svg)$/,
exclude: /fonts\//,
loader: 'file-loader',
options: {
name: '../images/[name].[ext]'
}
},
/**
* Compile ES6 to JavaScript in the build folder using babel-loader
*/
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
'env'
]
}
}
}
]
},
/**
* Additional configuration of Webpack plugins
*/
plugins: [
/**
* Default output path for compiled CSS files
*/
new ExtractTextPlugin('../css/[name].css'),
/**
* Minimize files when building in production mode
*/
new webpack.LoaderOptionsPlugin({
minimize: PRODUCTION_MODE
})
]
}