Skip to content

Commit b484c0f

Browse files
committed
2.3.0 - Update libraries and create multiple enviroments for webpack build
1 parent 3cc49ad commit b484c0f

7 files changed

+419
-182
lines changed

package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-template-framework7-vue-webpack",
3-
"version": "2.1.2",
3+
"version": "2.3.0",
44
"description": "Cordova template with framework7, vue 2 and webpack 2.",
55
"main": "index.js",
66
"scripts": {
@@ -20,7 +20,20 @@
2020
"template",
2121
"webpack",
2222
"vue.js",
23-
"vue"
23+
"vue",
24+
"mobile",
25+
"framework",
26+
"framework7",
27+
"ios",
28+
"iphone",
29+
"ipad",
30+
"apple",
31+
"phonegap",
32+
"touch",
33+
"app",
34+
"f7",
35+
"material",
36+
"android"
2437
],
2538
"author": "Caio Biodere",
2639
"license": "Apache-2.0"

template_src/hooks/hookers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ module.exports = function (ctx) {
202202
let defer = new Q.defer(),
203203
outText = '',
204204
isResultFound = false,
205-
args = [`"${webpackDevServerPath}"`, '--hot', '--inline', '--env.devserver', '--' + platform, `--public ${getRouterIpAddr()}:8081`],
205+
args = [`"${webpackDevServerPath}"`, '--hot', '--inline', '--env.devserver', '--' + platform, `--public ${getRouterIpAddr()}:8081`, '--env.devserver'],
206206
run = epipeBombPath
207207

208208
if (os.platform() === 'win32') {
209-
args = ['--hot', '--inline', '--env.devserver', '--' + platform, `--public ${getRouterIpAddr()}:8081`]
209+
args = ['--hot', '--inline', '--env.devserver', '--' + platform, `--public ${getRouterIpAddr()}:8081`, '--env.devserver']
210210
run = `"${webpackDevServerPath}.cmd"`
211211
}
212212

@@ -428,4 +428,4 @@ module.exports = function (ctx) {
428428
}
429429

430430
return deferral.promise
431-
}
431+
}

template_src/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"babel-preset-env": "^1.6.1",
1818
"cheerio": "^1.0.0-rc.2",
1919
"chokidar": "^2.0.4",
20-
"clean-webpack-plugin": "^0.1.15",
21-
"css-loader": "^1.0.0",
22-
"current-device": "^0.7.8",
20+
"clean-webpack-plugin": "^1.0.0",
21+
"css-loader": "^2.1.0",
22+
"current-device": "^0.8.0",
2323
"epipebomb": "^1.0.0",
24-
"extract-text-webpack-plugin": "next",
25-
"file-loader": "^2.0.0",
24+
"extract-text-webpack-plugin": "4.0.0-beta.0",
25+
"file-loader": "^3.0.1",
2626
"html-loader": "^0.5.1",
2727
"html-webpack-plugin": "^3.2.0",
2828
"node-sass": "^4.5.0",
@@ -44,12 +44,12 @@
4444
},
4545
"dependencies": {
4646
"font-awesome": "^4.7.0",
47-
"framework7": "^3.4.0",
48-
"framework7-icons": "^0.9.1",
49-
"framework7-vue": "^3.4.0",
50-
"material-design-icons": "^3.0.1",
47+
"framework7": "^3.6.5",
48+
"framework7-icons": "^2.1.1",
49+
"framework7-vue": "^3.6.5",
5150
"loglevel": "^1.4.1",
51+
"material-design-icons": "^3.0.1",
5252
"vue": "^2.5.17",
53-
"vuex": "^3.0.1"
53+
"vuex": "^3.1.0"
5454
}
5555
}

template_src/webpack.config.dev.js

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
4+
const webpack = require('webpack');
5+
const HtmlWebpackPlugin = require('html-webpack-plugin');
6+
const CordovaHtmlOutputPlugin = require('./webpack/plugins/CordovaHtmlOutputPlugin.js');
7+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
8+
const CleanPlugin = require('clean-webpack-plugin');
9+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
10+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
11+
12+
const entryFile = path.join(__dirname, 'src/main.js');
13+
const devServerPort = 8081;
14+
15+
module.exports = {
16+
entry: entryFile,
17+
mode: 'development',
18+
19+
resolve: {
20+
extensions: ['.js', '.json', '.vue'],
21+
modules: [path.join(__dirname, 'src'), 'node_modules'],
22+
alias: {
23+
'vue$': 'vue/dist/vue.common.js',
24+
'src': path.resolve(__dirname, 'src/'),
25+
'assets': path.resolve(__dirname, 'src/assets/'),
26+
'pages': path.resolve(__dirname, 'src/assets/vue/pages/'),
27+
'components': path.resolve(__dirname, 'src/assets/vue/components/')
28+
}
29+
},
30+
31+
output: {
32+
pathinfo: true,
33+
devtoolLineToLine: true,
34+
filename: '[hash].[name].js',
35+
sourceMapFilename: "[hash].[name].js.map",
36+
path: path.join(__dirname, 'www')
37+
},
38+
39+
module: {
40+
rules: [
41+
{
42+
test: /\.(png|jpe?g|gif)$/,
43+
loader: 'file-loader',
44+
options: { name: '[name].[ext]?[hash]' }
45+
},
46+
{
47+
test: /\.(woff2?|eot|ttf|otf|mp3|wav)(\?.*)?$/,
48+
loader: 'file-loader',
49+
options: { name: '[name].[ext]?[hash]' }
50+
},
51+
{
52+
test: /\.svg$/,
53+
loader: 'url-loader'
54+
},
55+
{
56+
test: /\.scss$/,
57+
loader: ['vue-style-loader', 'css-loader', 'sass-loader']
58+
},
59+
{
60+
test: /\.sass$/,
61+
loader: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax']
62+
},
63+
{
64+
test: /\.vue$/,
65+
exclude: /node_modules/,
66+
loader: 'vue-loader',
67+
options: {
68+
loaders: {
69+
js: {
70+
loader: 'babel-loader',
71+
options: {
72+
presets: ['env'],
73+
plugins: ['transform-object-rest-spread']
74+
}
75+
}
76+
}
77+
}
78+
},
79+
{
80+
test: /\.js$/,
81+
exclude: /node_modules(\/|\\)(?!(framework7|framework7-vue|template7|dom7)(\/|\\)).*/,
82+
use: {
83+
loader: 'babel-loader',
84+
options: {
85+
presets: ['env'],
86+
plugins: ['transform-runtime', 'transform-object-rest-spread']
87+
}
88+
}
89+
},
90+
{
91+
test: /\.css$/, use: ExtractTextPlugin.extract({
92+
fallback: "style-loader",
93+
use: "css-loader"
94+
})
95+
}
96+
]
97+
},
98+
99+
plugins: [
100+
new webpack.DefinePlugin({
101+
'process.env': {
102+
'NODE_ENV': JSON.stringify('development')
103+
}
104+
}),
105+
new HtmlWebpackPlugin({
106+
filename: 'index.html',
107+
template: 'src/index.ejs',
108+
platform: process.argv.length > 5 ? process.argv[5].replace(/[- ]/g, '') : "",
109+
inject: true,
110+
minify: {
111+
removeComments: true,
112+
removeScriptTypeAttributes: true,
113+
removeAttributeQuotes: true,
114+
useShortDoctype: true,
115+
decodeEntities: true,
116+
collapseWhitespace: true,
117+
minifyCSS: true
118+
}
119+
}),
120+
new VueLoaderPlugin(),
121+
new CordovaHtmlOutputPlugin(),
122+
new ExtractTextPlugin("styles.css")
123+
]
124+
}

template_src/webpack.config.js

Lines changed: 7 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,9 @@
1-
const path = require('path');
2-
const fs = require('fs');
3-
4-
const webpack = require('webpack');
5-
const HtmlWebpackPlugin = require('html-webpack-plugin');
6-
const CordovaHtmlOutputPlugin = require('./webpack/plugins/CordovaHtmlOutputPlugin.js');
7-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
8-
const CleanPlugin = require('clean-webpack-plugin');
9-
const ExtractTextPlugin = require("extract-text-webpack-plugin");
10-
const VueLoaderPlugin = require('vue-loader/lib/plugin');
11-
12-
const entryFile = path.join(__dirname, 'src/main.js');
13-
const devServerPort = 8081;
14-
15-
let config = function (env) {
16-
let returner = {
17-
entry: entryFile,
18-
mode: (env && typeof env.release !== 'undefined' && env.release) ? "production" : "development",
19-
20-
resolve: {
21-
extensions: ['.js', '.json', '.vue'],
22-
modules: [path.join(__dirname, 'src'), 'node_modules'],
23-
alias: {
24-
'vue$': 'vue/dist/vue.common.js',
25-
'src': path.resolve(__dirname, 'src/'),
26-
'assets': path.resolve(__dirname, 'src/assets/'),
27-
'pages': path.resolve(__dirname, 'src/assets/vue/pages/'),
28-
'components': path.resolve(__dirname, 'src/assets/vue/components/')
29-
}
30-
},
31-
32-
output: {
33-
pathinfo: true,
34-
devtoolLineToLine: true,
35-
filename: '[hash].[name].js',
36-
sourceMapFilename: "[hash].[name].js.map",
37-
path: path.join(__dirname, 'www')
38-
},
39-
40-
module: {
41-
rules: [
42-
{
43-
test: /\.(png|jpe?g|gif)$/,
44-
loader: 'file-loader',
45-
options: { name: '[name].[ext]?[hash]' }
46-
},
47-
{
48-
test: /\.(woff2?|eot|ttf|otf|mp3|wav)(\?.*)?$/,
49-
loader: 'file-loader',
50-
options: { name: '[name].[ext]?[hash]' }
51-
},
52-
{
53-
test: /\.svg$/,
54-
loader: 'url-loader'
55-
},
56-
{
57-
test: /\.scss$/,
58-
loader: ['vue-style-loader', 'css-loader', 'sass-loader']
59-
},
60-
{
61-
test: /\.sass$/,
62-
loader: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax']
63-
},
64-
{
65-
test: /\.vue$/,
66-
exclude: /node_modules/,
67-
loader: 'vue-loader',
68-
options: {
69-
loaders: {
70-
js: {
71-
loader: 'babel-loader',
72-
options: {
73-
presets: ['env'],
74-
plugins: ['transform-object-rest-spread']
75-
}
76-
}
77-
}
78-
}
79-
},
80-
{
81-
test: /\.js$/,
82-
exclude: /node_modules(\/|\\)(?!(framework7|framework7-vue|template7|dom7)(\/|\\)).*/,
83-
use: {
84-
loader: 'babel-loader',
85-
options: {
86-
presets: ['env'],
87-
plugins: ['transform-runtime', 'transform-object-rest-spread']
88-
}
89-
}
90-
}
91-
]
92-
},
93-
94-
plugins: [
95-
new webpack.DefinePlugin({
96-
'process.env': {
97-
'NODE_ENV': JSON.stringify((env && typeof env !== "undefined" && env.release) ? 'production' : 'development')
98-
}
99-
}),
100-
new HtmlWebpackPlugin({
101-
filename: 'index.html',
102-
template: 'src/index.ejs',
103-
platform: process.argv.length > 5 ? process.argv[5].replace(/[- ]/g, '') : "",
104-
inject: true,
105-
minify: {
106-
removeComments: true,
107-
removeScriptTypeAttributes: true,
108-
removeAttributeQuotes: true,
109-
useShortDoctype: true,
110-
decodeEntities: true,
111-
collapseWhitespace: true,
112-
minifyCSS: true
113-
}
114-
}),
115-
new VueLoaderPlugin()
116-
]
117-
}
118-
1+
module.exports = function (env) {
1192
if (typeof env === 'undefined' || typeof env.devserver === 'undefined') {
120-
returner.plugins.push(new CordovaHtmlOutputPlugin())
121-
returner.plugins.push(new ExtractTextPlugin("styles.css"))
122-
returner.module.rules.push({
123-
test: /\.css$/, use: ExtractTextPlugin.extract({
124-
fallback: "style-loader",
125-
use: "css-loader"
126-
})
127-
})
128-
}
129-
130-
if (env) {
131-
if (typeof env.devserver !== 'undefined' && env.devserver) {
132-
returner.module.rules.push({
133-
test: /\.css$/, loader: ['style-loader', 'css-loader']
134-
})
135-
returner.entry = [
136-
entryFile,
137-
]
138-
returner.output.publicPath = "/"
139-
returner.devtool = "eval"
140-
returner.devServer = {
141-
contentBase: path.join(__dirname, "www"),
142-
port: devServerPort,
143-
stats: { colors: true },
144-
watchOptions: {
145-
aggregateTimeout: 300,
146-
poll: 100,
147-
ignored: /node_modules|platforms/,
148-
},
149-
headers: {
150-
"Access-Control-Allow-Origin": "*"
151-
},
152-
host: "0.0.0.0"
153-
}
154-
returner.plugins.push(new webpack.NamedModulesPlugin())
155-
} else if (typeof env.release !== 'undefined' && env.release) {
156-
returner.plugins.push(new CleanPlugin("www", {
157-
root: path.join(__dirname, "."),
158-
dry: false,
159-
verbose: false,
160-
exclude: ["index.html"]
161-
}))
162-
returner.plugins.push(new UglifyJsPlugin())
163-
}
3+
return require('./webpack.config.dev');
4+
} else if (typeof env.devserver !== 'undefined' && env.devserver) {
5+
return require('./webpack.config.server');
6+
} else if (typeof env.release !== 'undefined' && env.release) {
7+
return require('./webpack.config.release');
1648
}
165-
166-
return returner
167-
}
168-
169-
module.exports = config
9+
}

0 commit comments

Comments
 (0)