-
Notifications
You must be signed in to change notification settings - Fork 224
/
webpack.config.dev.js
184 lines (180 loc) · 4.9 KB
/
webpack.config.dev.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
179
180
181
182
183
184
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const path = require('path');
const settings = require('./tasks/helper').init().readSettingsFile()
.template.development;
module.exports = {
mode: 'development',
entry: {
bundle: [
'core-js/features/array',
'core-js/features/string/ends-with',
'core-js/features/string/starts-with',
'core-js/features/object',
'core-js/features/symbol',
'core-js/features/promise',
'regenerator-runtime/runtime',
'./app/main.js',
], //Our starting point for our development.
},
output: {
path: path.join(__dirname, '/dist/debug/'),
filename: 'dashboard.assets/js/[name].js'
},
plugins: [
new ESLintPlugin({
extensions: [`js`, `jsx`],
}),
new webpack.optimize.LimitChunkCountPlugin({maxChunks: 1}),
new HtmlWebpackPlugin(Object.assign({
template: settings.src,
title: 'Project Fauxton',
filename: 'index.html',
generationLabel: 'Fauxton Dev',
generationDate: new Date().toISOString()
}, settings.variables)),
new MiniCssExtractPlugin({
filename: 'dashboard.assets/css/styles.[chunkhash].css',
chunkFilename: 'dashboard.assets/css/styles.[chunkhash].css'
}),
new webpack.LoaderOptionsPlugin({
debug: true
})
],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: ['/node_modules/'],
use: [{
loader: 'babel-loader'
}],
},
{
test: require.resolve('jquery'),
use: [{
loader: 'expose-loader',
options: {
exposes: ['jQuery', '$']
},
},
]},
{
test: require.resolve("backbone"),
use: [{
loader: 'expose-loader',
options: {
exposes: [{
globalName: 'Backbone',
override: true,
}],
},
}]
},
{
// We load Sass files through the extract text plugin.
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: "../../",
},
},
"css-loader",
{
loader: "sass-loader",
options: {
sassOptions: {
includePaths: ["node_modules"],
},
additionalData: `$largeLogoPath: "${settings.variables.largeLogoPath}"; $smallLogoPath: "${settings.variables.smallLogoPath}";`,
sourceMap: false,
},
},
],
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../../'
},
},
"css-loader"
]
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
generator: {
filename: 'dashboard.assets/fonts/[name][ext]'
},
},
{
test: /\.woff2(\?\S*)?$/,
type: 'asset/resource',
generator: {
filename: 'dashboard.assets/fonts/[name][ext]'
},
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
generator: {
filename: 'dashboard.assets/fonts/[name][ext]'
},
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
generator: {
filename: 'dashboard.assets/fonts/[name][ext]'
},
},
{
test: /\.png(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
generator: {
filename: 'dashboard.assets/img/[name][ext]'
},
},
{
test: /\.gif(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
generator: {
filename: 'dashboard.assets/img/[name][ext]'
},
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
generator: {
filename: 'dashboard.assets/img/[name][ext]'
},
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx'], //We can use .js and React's .jsx files using Babel
alias: {
"underscore": "lodash",
}
},
devtool: 'source-map'
};