Skip to content

Commit 686ef32

Browse files
committed
updated to v1.7.0
1 parent 9a1c18a commit 686ef32

File tree

12 files changed

+6033
-4628
lines changed

12 files changed

+6033
-4628
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## **v1.7.0 (2018-07-01)**
2+
3+
### Added
4+
* Variables in `_variables.sass` can be used in `*.vue` files
5+
* Webpack removes unused css from `app.[hash].css` file
6+
* A new command `make:menu-page`
7+
* screenshot for theme
8+
9+
### Changed
10+
* Migrated from webpack 3 to webpack 4
11+
* Moved Luna CLIs [docs](https://github.com/suomato/luna) to `suomato/luna` repository
12+
* Updated composer packages (Now PHP version must be at least v7.0!)
13+
* Updated Timber to v1.7.1
14+
15+
### Removed
16+
* `dd()` from `/app/helpers.php`. This function comes now with the `symfony/var-dumper`
17+
118
## **v1.6.0 (2018-03-30)**
219

320
### Added

README.md

Lines changed: 9 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center"><img width="220" src="https://raw.githubusercontent.com/suomato/base-camp/develop/resources/assets/images/base-camp-logo.png"></p>
22

33
<p align="center">
4-
<a href='https://packagist.org/packages/suomato/base-camp'><img src='https://poser.pugx.org/suomato/base-camp/v/stable.svg' alt="Dependency Status" /></a> <a href='https://packagist.org/packages/suomato/base-camp'><img src='https://poser.pugx.org/suomato/base-camp/v/unstable.svg' alt="Dependency Status" /></a> <a href='https://www.versioneye.com/user/projects/59b4dcb90fb24f002a9812a7'><img src='https://www.versioneye.com/user/projects/59b4dcb90fb24f002a9812a7/badge.svg?style=flat-square' alt="Dependency Status" /></a> <a href="https://packagist.org/packages/suomato/base-camp"><img src="https://poser.pugx.org/suomato/base-camp/license.svg" alt="License"></a>
4+
<a href='https://packagist.org/packages/suomato/base-camp'><img src='https://poser.pugx.org/suomato/base-camp/v/stable.svg' alt="Dependency Status" /></a> <a href='https://packagist.org/packages/suomato/base-camp'><img src='https://poser.pugx.org/suomato/base-camp/v/unstable.svg' alt="Dependency Status" /></a> <a href="https://packagist.org/packages/suomato/base-camp"><img src="https://poser.pugx.org/suomato/base-camp/license.svg" alt="License"></a>
55
</p>
66

77
## About Base Camp
@@ -21,14 +21,15 @@
2121
* Split javascript code to two chunks, app.js and vendor.js
2222
* [Vuejs](https://vuejs.org/) for boosting frontend development
2323
* [BrowserSync](https://www.browsersync.io/) for synchronised browser testing
24-
* [Luna](https://github.com/suomato/base-camp#luna-command-line-interface) (Command-line interface included with Base Camp)
24+
25+
* [Luna](https://github.com/suomato/luna) (Command-line interface included with Base Camp)
2526
* [WooCommerce](https://woocommerce.com/) support with basic boilerplate.
2627

2728
## Requirements
28-
* [Wordpress](https://wordpress.org/) >= v4.9.4
29-
* [Composer](https://getcomposer.org/download/) >= v1.6.3
30-
* [PHP](http://php.net/manual/en/install.php) >= v5.6 (Recommended >= v7.0)
31-
* [Yarn](https://yarnpkg.com/en/) >= v1.5.1 **or** [npm](https://www.npmjs.com/) >= v5.6.0
29+
* [Wordpress](https://wordpress.org/) >= v4.9.6
30+
* [Composer](https://getcomposer.org/download/) >= v1.6.5
31+
* [PHP](http://php.net/manual/en/install.php) >= v7.0
32+
* [Yarn](https://yarnpkg.com/en/) >= v1.7.0 **or** [npm](https://www.npmjs.com/) >= v6.1.0
3233
* [Nodejs](https://nodejs.org/en/) >= v8.11.1
3334

3435
## Installation
@@ -37,6 +38,7 @@
3738
* `yarn` **or** `npm install`
3839
* define your custom webpack config to `build/config.js` file
3940
* `yarn watch` **or** `npm run watch`
41+
* Remember to activate Timber plugin!
4042
* Happy developing :)
4143

4244
## Structure
@@ -81,96 +83,5 @@ base-camp/ # Theme root
8183

8284
## Luna (Command-line interface)
8385

84-
#### Make Custom Post Type
85-
86-
> This Command helps you to create a new Custom Post Type very fast.
87-
88-
```
89-
php luna make:custom-post-type {name}
90-
```
91-
92-
> The argument is singular form. if noun have irregular plural which do not behave in standard way(singular+s),
93-
exception can be defined by plural option e.g.
94-
95-
```
96-
php luna make:custom-post-type person --plural=people
97-
```
98-
99-
> The new file is created to `/app/config/wp/custom-post-types/{name}.php`
100-
101-
#### Make Route
102-
103-
> This Command helps you to create a new route for WordPress API clearer and faster way.
104-
105-
```
106-
php luna make:route {name}
107-
```
108-
109-
> The new file is created to `/app/config/wp/routes/{name}.php`. The created file comes with the well documented boilerplate.
110-
111-
#### Make Shortcode
112-
113-
> This Command helps you to create a new shortcode with very clean boilerplate.
114-
115-
```
116-
php luna make:shortcode {name}
117-
```
118-
119-
> The new file is created to `/app/config/wp/shortcodes/{name}.php`.
120-
121-
##### Example
122-
123-
Run command:
124-
125-
```
126-
php luna make:shortcode LuckyNumber
127-
```
128-
129-
Then define some data
130-
```
131-
/**
132-
* @var string Shortcode name
133-
*/
134-
protected $shortcode = 'lucky_number';
135-
136-
/**
137-
* @var array|string An associative array of attributes
138-
*/
139-
protected $attributes = [
140-
'number' => 7,
141-
];
142-
143-
/**
144-
* Return template of shortcode
145-
*
146-
* @param $attr An associative array of attributes
147-
* @param $content Enclosed content
148-
*
149-
* @return mixed
150-
*/
151-
protected function template($attr, $content)
152-
{
153-
return 'This is my lucky number: ' . $attr['number'];
154-
}
155-
```
156-
157-
> Now shortcode `[lucky_number]` generates `This is my lucky number: 7` and `[lucky_number number="13"]` generates `This is my lucky number: 13`
158-
159-
> It is also possible to use power of Timber. In template function you can return Timber view instead of string like this:
160-
161-
```
162-
// resources/views/shortcodes/lucky-number.twig
163-
164-
<p>This is my lucky number: {{ number }}</p>
165-
166-
******************************************************************
167-
168-
// app/config/wp/shortcodes/LuckyNumber.php
169-
170-
protected function template($attr, $content)
171-
{
172-
return \Timber::compile('shortcodes/lucky-number.twig', $attr);
173-
}
174-
```
175-
86+
> [Docs](https://github.com/suomato/luna)
17687

app/helpers.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
<?php
22

3-
/**
4-
* Debug helper
5-
*
6-
* Dumps the variable and ends the execution of the app
7-
*
8-
* @since 1.0.0
9-
*
10-
* @param $data
11-
*/
12-
function dd($data)
13-
{
14-
die(dump($data));
15-
}
16-
173
/**
184
* Return url of compiled style or script file
195
*

build/webpack.config.js

Lines changed: 85 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const webpack = require('webpack');
22
const path = require('path');
33
const glob = require('glob');
4-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
55
const CleanWebpackPlugin = require('clean-webpack-plugin');
6+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7+
const PurgecssPlugin = require('purgecss-webpack-plugin');
68
const ManifestPlugin = require('webpack-manifest-plugin');
79
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
810
const config = require('./config');
@@ -11,6 +13,19 @@ const inProduction = process.env.NODE_ENV === 'production';
1113
const styleHash = inProduction ? 'contenthash' : 'hash';
1214
const scriptHash = inProduction ? 'chunkhash' : 'hash';
1315

16+
// LOADER HELPERS
17+
const extractCss = {
18+
loader: MiniCssExtractPlugin.loader,
19+
options: {
20+
publicPath: `${config.assetsPath}static/css/`,
21+
},
22+
};
23+
24+
const cssLoader = {
25+
loader: 'css-loader',
26+
options: { minimize: inProduction },
27+
};
28+
1429
module.exports = {
1530
entry: {
1631
app: glob.sync('./resources/assets/+(s[ac]ss|js)/main.+(s[ac]ss|js)'),
@@ -28,41 +43,49 @@ module.exports = {
2843
{
2944
test: /\.vue$/,
3045
loader: 'vue-loader',
31-
options: {
32-
loaders: {
33-
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
34-
// the "scss" and "sass" values for the lang attribute to the right configs here.
35-
// other preprocessors should work out of the box, no loader config like this necessary.
36-
scss: ['vue-style-loader', 'css-loader', 'sass-loader'],
37-
sass: [
38-
'vue-style-loader',
39-
'css-loader',
40-
'sass-loader?indentedSyntax',
41-
],
42-
},
43-
// other vue-loader options go here
44-
},
4546
},
4647
{
47-
test: /\.s[ac]ss$/,
48-
use: ExtractTextPlugin.extract({
49-
fallback: 'style-loader',
50-
use: [
51-
{
52-
loader: 'css-loader',
53-
options: { minimize: inProduction },
54-
},
55-
{
56-
loader: 'sass-loader',
57-
options: { sourceMap: true },
48+
test: /\.js$/,
49+
loader: 'babel-loader',
50+
},
51+
{
52+
test: /\.css$/,
53+
use: ['vue-style-loader', extractCss, cssLoader],
54+
},
55+
{
56+
test: /\.scss$/,
57+
use: [
58+
'vue-style-loader',
59+
extractCss,
60+
cssLoader,
61+
{
62+
loader: 'sass-loader',
63+
options: {
64+
includePaths: [
65+
path.resolve(__dirname, '../resources/assets/sass'),
66+
],
67+
data: '@import "variables";',
5868
},
59-
],
60-
}),
69+
},
70+
],
6171
},
6272
{
63-
test: /\.js$/,
64-
exclude: /node_modules/,
65-
loader: 'babel-loader',
73+
test: /\.sass$/,
74+
use: [
75+
'vue-style-loader',
76+
extractCss,
77+
cssLoader,
78+
{
79+
loader: 'sass-loader',
80+
options: {
81+
indentedSyntax: true,
82+
includePaths: [
83+
path.resolve(__dirname, '../resources/assets/sass'),
84+
],
85+
data: '@import "variables";',
86+
},
87+
},
88+
],
6689
},
6790
{
6891
test: /\.(png|jpe?g|gif|svg)$/,
@@ -91,6 +114,19 @@ module.exports = {
91114
],
92115
},
93116

117+
optimization: {
118+
splitChunks: {
119+
cacheGroups: {
120+
vendor: {
121+
chunks: 'all',
122+
name: 'vendor',
123+
test: 'vendor',
124+
enforce: true,
125+
},
126+
},
127+
},
128+
},
129+
94130
resolve: {
95131
alias: {
96132
vue$: 'vue/dist/vue.esm.js',
@@ -100,34 +136,30 @@ module.exports = {
100136
},
101137

102138
plugins: [
103-
new ExtractTextPlugin(`css/[name].[${styleHash}].css`),
104-
105-
new BrowserSyncPlugin({
106-
host: 'localhost',
107-
port: 3000,
108-
proxy: config.devUrl, // YOUR DEV-SERVER URL
109-
files: ['./*.php', './resources/views/**/*.twig', './static/*.*'],
110-
}),
139+
new VueLoaderPlugin(),
111140

112141
new CleanWebpackPlugin(['static/css/*', 'static/js/*'], {
142+
root: path.join(__dirname, '../'),
113143
watch: true,
114-
root: path.resolve(__dirname, '../'),
144+
}),
145+
146+
new MiniCssExtractPlugin({
147+
filename: `css/[name].[${styleHash}].css`,
148+
}),
149+
150+
new PurgecssPlugin({
151+
paths: () =>
152+
glob.sync(path.join(__dirname, '../resources/**/*'), { nodir: true }),
153+
only: ['app'],
115154
}),
116155

117156
new ManifestPlugin(),
118-
new webpack.optimize.CommonsChunkPlugin({
119-
name: 'vendor',
120-
filename: `js/[name].[${scriptHash}].js`,
157+
158+
new BrowserSyncPlugin({
159+
host: 'localhost',
160+
port: 3000,
161+
proxy: config.devUrl, // YOUR DEV-SERVER URL
162+
files: ['./*.php', './resources/views/**/*.twig', './static/*.*'],
121163
}),
122164
],
123165
};
124-
125-
if (inProduction) {
126-
module.exports.plugins.push(new webpack.optimize.UglifyJsPlugin());
127-
128-
module.exports.plugins.push(new webpack.DefinePlugin({
129-
'process.env': {
130-
NODE_ENV: '"production"',
131-
},
132-
}));
133-
}

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
},
3333
"require": {
3434
"php": "^7.0",
35-
"wpackagist-plugin/timber-library": "1.5.2",
36-
"symfony/var-dumper": "^3.3",
37-
"symfony/console": "^3.3",
35+
"wpackagist-plugin/timber-library": "1.7.1",
36+
"symfony/var-dumper": "^4.1",
37+
"symfony/console": "^4.1",
3838
"league/flysystem": "^1.0",
39-
"symfony/finder": "^3.3",
40-
"suomato/luna": "^1.1.0",
39+
"symfony/finder": "^4.1",
40+
"suomato/luna": "^1.2",
4141
"vlucas/phpdotenv": "^2.4"
4242
},
4343
"autoload": {

0 commit comments

Comments
 (0)