-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
179 lines (164 loc) · 4.48 KB
/
webpack.mix.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
/**
* Laravel Mix configuration file.
*
* Laravel Mix is a layer built on top of Webpack that simplifies much of the
* complexity of building out a Webpack configuration file. Use this file
* to configure how your assets are handled in the build process.
*
* @link https://laravel.com/docs/5.8/mix
*/
// Import required packages.
const mix = require("laravel-mix");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
require("laravel-mix-polyfill");
require("laravel-mix-svg-sprite");
/*
* Disable all notifications.
*/
mix.disableNotifications();
/*
* -----------------------------------------------------------------------------
* Build Process
* -----------------------------------------------------------------------------
* The section below handles processing, compiling, transpiling, and combining
* all of the theme's assets into their final location. This is the meat of the
* build process.
* -----------------------------------------------------------------------------
*/
/*
* Sets the development path to assets. By default, this is the `/resources`
* folder in the theme.
*/
const devPath = "resources";
const distPath = "assets";
/*
* Sets the path to the generated assets. By default, this is the root folder in
* the theme. If doing something custom, make sure to change this everywhere.
*/
mix.setPublicPath("./");
/*
* Set Laravel Mix options.
*
* @link https://laravel.com/docs/5.6/mix#postcss
* @link https://laravel.com/docs/5.6/mix#url-processing
*/
mix.options({
postCss: [require("postcss-preset-env")()],
processCssUrls: false,
});
/*
* Versioning and cache busting. Append a unique hash for production assets. If
* you only want versioned assets in production, do a conditional check for
* `mix.inProduction()`.
*
* @link https://laravel.com/docs/5.6/mix#versioning-and-cache-busting
*/
mix.version();
/*
* Compile JavaScript.
*
* @link https://laravel.com/docs/5.6/mix#working-with-scripts
*/
mix
.js(`${devPath}/js/admin.js`, `${distPath}/js`)
.js(`${devPath}/js/frontend.js`, `${distPath}/js`)
.js(`${devPath}/js/calendar.js`, `${distPath}/js`);
/*
* Compile CSS. Mix supports Sass, Less, Stylus, and plain CSS, and has functions
* for each of them.
*
* @link https://laravel.com/docs/5.6/mix#working-with-stylesheets
* @link https://laravel.com/docs/5.6/mix#sass
* @link https://github.com/sass/node-sass#options
*/
// Sass configuration.
var sassConfig = {
outputStyle: "compressed",
indentType : "tab",
indentWidth: 1,
};
// Compile SASS/CSS.
mix
.sass( `${devPath}/scss/admin.scss`, `${distPath}/css` )
.options( {
sassOptions: sassConfig,
postCss : [
require( "cssnano" )( {
preset: [
"default",
{
discardComments: {
removeAll: true,
},
},
],
} ),
],
} )
.sass(
`${devPath}/scss/frontend.scss`,
`${distPath}/css`
)
.options( {
sassOptions: sassConfig,
postCss : [
require( "cssnano" )( {
preset: [
"default",
{
discardComments: {
removeAll: true,
},
},
],
} ),
],
} );
/*
* Add custom Webpack configuration.
*
* Laravel Mix doesn't currently minimize images while using its `.copy()`
* function, so we're using the `CopyWebpackPlugin` for processing and copying
* images into the distribution folder.
*
* @link https://laravel.com/docs/5.6/mix#custom-webpack-configuration
* @link https://webpack.js.org/configuration/
*/
mix.webpackConfig({
stats: "minimal",
performance: { hints: false },
externals: { jquery: "jQuery" },
plugins: [
// @link https://github.com/webpack-contrib/copy-webpack-plugin
new CopyWebpackPlugin( {
patterns: [
{
from : `${devPath}/fonts`,
to : `${distPath}/fonts`,
noErrorOnMissing: true
}
]
} )
]
});
if (process.env.sync) {
/*
* Monitor files for changes and inject your changes into the browser.
*
* @link https://laravel.com/docs/5.6/mix#browsersync-reloading
*/
mix.browserSync({
notify: false,
proxy: process.env.MIX_PROXY,
host: process.env.MIX_HOST,
open: "external",
port: process.env.MIX_PORT,
https: {
key: process.env.MIX_KEY,
cert: process.env.MIX_CRT,
},
files: [`${devPath}/**/*`],
});
}