-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·166 lines (156 loc) · 3.52 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
const webpack = require('webpack');
const loriConfig = require('./lori.config');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
/**
* Now the output file and path
* this is where our js file will be output
* to at compilation time
*/
module.exports.output = {
path: loriConfig.publicDir+'/assets',
filename: 'app.js',
publicPath: 'assets/'
};
/**
* Define our resolve object
* it is empty by default
*/
module.exports.resolve = {};
/**
* Watch webpack when not in production
*/
module.exports.watch = true;
/**
* Within our resolve object we will define
* aliaes we want to resolve.
*/
module.exports.resolve.alias = {
ENV: loriConfig.env,
AppConfigs: loriConfig.devDir+'/configs/app.config.js',
RoutesConfig: loriConfig.devDir+'/configs/routes.config.js'
};
/**
* Now we define our modules
* this will contains the rules and loaders
* used to translate and compile our application files
* into one file (output file)
*/
module.exports.module = {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
include: loriConfig.devDir
},
{
test: /\.less$/,
use: loriConfig.extractLess.extract({
fallback: 'style-loader',
use: [
{
'loader': 'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
},
{
'loader': 'resolve-url-loader'
},
{
'loader': 'less-loader'
}
]
}),
include: loriConfig.devDir
},
{
test: /\.s?css$/,
use: loriConfig.extractScss.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader?modules&modules=true&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
},
{
loader: 'resolve-url-loader'
},
{
loader: 'sass-loader'
}
]
}),
include: loriConfig.devDir
},
{
test: /\.jpe?g$|\.gif$|\.png$|\.svg$/,
use: {
loader: 'file-loader',
options: {
name: 'images/[sha512:hash:base64:7].[ext]',
outputPath: '',
publicPath: '/assets/'
}
},
include: loriConfig.devDir
},
{
test: /\.(woff2?|ttf|eot|otf)$/,
use:{
loader: 'file-loader',
options:{
name: 'fonts/[name].[ext]',
outputPath: '',
publicPath: '/assets/'
}
},
include: loriConfig.devDir
}
]
};
/**
* We will start by defining our plugins.
* These are environment specific, we will add
* more plugins as the environment may require
*/
module.exports.plugins = [
loriConfig.extractLess,
loriConfig.extractScss,
new FriendlyErrorsWebpackPlugin()
];
// if in production
if(loriConfig.isProduction){
// concat extra plugins to webpack config
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
},
comments: false,
}),
new webpack.optimize.AggressiveMergingPlugin()
]);
}
/**
* set devtool
*/
module.exports.devtool = loriConfig.isProduction ? 'cheap-module-source-map' : 'source-map';
/*
*******************************
* Stats
*******************************
*
* By default, Webpack spits a lot of information out to the terminal,
* each you time you compile. Let's keep things a bit more minimal
* and hide a few of those bits and pieces. Adjust as you wish.
*
*/
module.exports.stats = {
hash: false,
version: false,
timings: false,
children: false,
errors: false
};
module.exports.performance = { hints: false };