Skip to content

Commit cf5fa76

Browse files
committed
changes
- update dependencies - add beautify html options - disable webpack resolve symlinks - add babel loader - add html source and context options - drop webpack-rtl-plugin and webpack-rtl-wrap-plugin in favor of postcss-rtl
1 parent f1cfecb commit cf5fa76

File tree

2 files changed

+60
-41
lines changed

2 files changed

+60
-41
lines changed

package.json

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
{
22
"name": "theme-mix",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"author": "FrontendMatter <contact@frontendmatter.com> (http://www.frontendmatter.com)",
55
"dependencies": {
6-
"async": "^2.4.1",
7-
"browser-sync": "^2.26.3",
6+
"async": "^3.2.0",
7+
"browser-sync": "^2.26.12",
88
"browser-sync-webpack-plugin": "^2.2.2",
9-
"del": "^3.0.0",
9+
"del": "^5.1.0",
1010
"front-matter-loader": "^0.2.0",
1111
"fs-simple-cache": "^1.2.0",
1212
"jsbeautify-loader": "^0.3.0",
1313
"laravel-mix": "4.0.4",
1414
"lodash.merge": "^4.6.0",
1515
"merge-config": "^2.0.0",
16-
"node-sass": "^4.11.0",
16+
"node-sass": "^4.14.1",
1717
"nunjucks-html-loader": "github:lazabogdan/nunjucks-html-loader#front-matter",
1818
"object-assign": "^4.1.1",
19-
"sass": "^1.15.2",
20-
"sass-loader": "^7.1.0",
21-
"vnu-jar": "^18.11.5",
22-
"webpack-rtl-plugin": "^1.6.0",
23-
"webpack-rtl-wrap-plugin": "^1.2.0",
24-
"webpack-sources": "^1.3.0",
25-
"yargs": "^12.0.5"
19+
"postcss-rtl": "^1.7.3",
20+
"sass": "^1.26.10",
21+
"sass-loader": "^7.3.1",
22+
"vnu-jar": "^20.6.30",
23+
"webpack-sources": "^1.4.3",
24+
"yargs": "^16.0.3"
2625
},
2726
"description": "Webpack config for FrontendMatter HTML Themes",
2827
"main": "webpack.mix.js",

webpack.mix.js

+49-29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const glob = require('glob')
33
const argv = require('yargs').argv
44
const del = require('del')
55
const merge = require('webpack-merge').smart
6+
const webpack = require('webpack')
67
let webpackConfig = {}
78

89
///////////////////
@@ -20,8 +21,6 @@ config.merge({
2021
sass: true,
2122
html: true,
2223
},
23-
enableCssThemes: false,
24-
// create additional .rtl.css
2524
enableCssRTL: false,
2625
// expose globals
2726
expose: [],
@@ -41,6 +40,8 @@ config.merge({
4140
cssDest: 'dist/assets/css',
4241
jsSrc: 'src/js/**/**.{js,vue}',
4342
jsDest: 'dist/assets/js',
43+
htmlSrc: 'src/html/pages/**/**.html',
44+
htmlContext: './src/html/pages',
4445
htmlSearchPaths: [
4546
'./src/html'
4647
],
@@ -73,6 +74,7 @@ catch (e) {
7374
///////////////////////////////
7475

7576
mix.options(config.get('laravelMixOptions'))
77+
mix.setPublicPath('.')
7678

7779
/////////////
7880
// Aliases //
@@ -157,9 +159,7 @@ if (__RUN === 'copy' || (!__RUN && config.get('runTasks:copy'))) {
157159
// SASS //
158160
//////////
159161

160-
// npm run development -- --env.theme dark
161-
const __THEME = argv.env ? argv.env.theme || 'default' : 'default'
162-
162+
// npm run development -- --env.run sass
163163
mix.extend('addSassIncludePaths', function(webpackConfig) {
164164
const Vue = require('laravel-mix/src/components/Vue')
165165
const vue = new Vue()
@@ -208,37 +208,19 @@ if (__RUN === 'sass' || (!__RUN && config.get('runTasks:sass'))) {
208208
includePaths: ['node_modules']
209209
}
210210

211-
if (config.get('enableCssThemes')) {
212-
// inject $theme variable
213-
sassOptions.data = '$theme: ' + __THEME + ';'
214-
__DIST_CSS += '/themes/' + __THEME
215-
}
216-
217211
for (let file of glob.sync(config.get('sassSrc'), { ignore: '**/_*' })) {
218212
mix.sass(file, __DIST_CSS, sassOptions)
219213
}
220214

215+
221216
/////////
222217
// RTL //
223218
/////////
224219

225220
if (config.get('enableCssRTL')) {
226-
const WebpackRTLPlugin = require('webpack-rtl-plugin')
227-
const WebpackRTLWrapPlugin = require('webpack-rtl-wrap-plugin')
228-
const cacheDirectory = path.resolve(path.join('temp', 'rtl', __THEME))
229-
230-
del.sync(cacheDirectory)
231-
232-
webpackConfig = merge(webpackConfig, {
233-
plugins: [
234-
// Creates .rtl.css
235-
new WebpackRTLPlugin({
236-
minify: false
237-
}),
238-
// wraps CSS into [dir=ltr|rtl]
239-
new WebpackRTLWrapPlugin({
240-
cacheDirectory
241-
})
221+
mix.options({
222+
postCss: [
223+
require('postcss-rtl')
242224
]
243225
})
244226
}
@@ -253,15 +235,15 @@ if (__RUN === 'html' || (!__RUN && config.get('runTasks:html'))) {
253235
let Entry = require('laravel-mix/src/builder/Entry')
254236
let entry = new Entry()
255237

256-
for (let file of glob.sync('src/html/pages/*.html', { ignore: '**/_*' })) {
238+
for (let file of glob.sync(config.get('htmlSrc'), { ignore: '**/_*' })) {
257239
entry.add('mix', path.resolve(file))
258240
}
259241

260242
let loaders = [{
261243
loader: 'file-loader',
262244
options: {
263245
name: config.get('htmlDest'),
264-
context: './src/html/pages',
246+
context: config.get('htmlContext'),
265247
useRelativePath: false
266248
}
267249
}]
@@ -331,6 +313,44 @@ if (Config.webpackConfig) {
331313
webpackConfig = merge(Config.webpackConfig, webpackConfig)
332314
}
333315

316+
mix.webpackConfig({
317+
plugins: [
318+
new webpack.LoaderOptionsPlugin({
319+
// test: /\.xxx$/, // may apply this only for some modules
320+
options: {
321+
jsBeautify: {
322+
"html": {
323+
"allowed_file_extensions": ["html", "xhtml", "shtml", "xml", "svg"],
324+
"indent_size": 4,
325+
"indent_inner_html": true,
326+
"wrap_attributes": "force-aligned",
327+
"max_preserve_newlines": 1
328+
}
329+
}
330+
}
331+
})
332+
],
333+
resolve: {
334+
symlinks: false,
335+
modules: [
336+
path.resolve(__dirname, '..', 'node_modules'),
337+
'node_modules'
338+
],
339+
},
340+
module: {
341+
rules: [{
342+
test: /\.jsx?$/,
343+
exclude: /(node_modules\/(core-js|@babel\b)|bower_components)/,
344+
use: [
345+
{
346+
loader: 'babel-loader',
347+
options: Config.babel()
348+
}
349+
]
350+
}]
351+
}
352+
})
353+
334354
mix.webpackConfig(webpackConfig)
335355

336356
/////////////////

0 commit comments

Comments
 (0)