Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Commit 5b9935a

Browse files
committed
[Dependencies] Update dependencies and apply migration from latest dependencies upgrade guides.
- babel to 7.0.0 - vue-loader from v14 to v15 - jest configuration - webpack configuration
1 parent efb1441 commit 5b9935a

34 files changed

+1176
-1717
lines changed

.babelrc

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"presets": [
3-
"@babel/preset-env",
4-
"@babel/preset-stage-0"
3+
"@babel/preset-env"
54
],
65
"plugins": [
76
"@babel/plugin-transform-runtime",
@@ -10,8 +9,7 @@
109
"env": {
1110
"test": {
1211
"presets": [
13-
"@babel/preset-env",
14-
"@babel/preset-stage-0"
12+
"@babel/preset-env"
1513
],
1614
"plugins": [
1715
"@babel/plugin-transform-runtime"

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
# Node
99
node_modules
10-
yarn.lock
1110
package-lock.json
1211

1312

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ Features:
1818

1919
### Install Dependencies
2020
```bash
21-
npm install
21+
yarn
2222
```
2323

2424
### Development
2525
```bash
26-
npm run dev
26+
yarn run dev
2727
```
2828

2929
### Build Production Level files
3030
```bash
31-
npm run build
31+
yarn run build
3232
```
3333

3434
### Test
3535
```bash
36-
npm run test
36+
yarn test
3737
```
3838

3939

config/base.config.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ let baseConfig = {
33
dir: {
44
src: 'src',
55
build: 'build',
6-
dist: 'dist',
6+
dist: {
7+
root: 'dist',
8+
js: 'static/js',
9+
css: 'static/css',
10+
img: 'static/img',
11+
manifest: 'static/manifest'
12+
},
713
cache: '.cache',
814
test: {
915
unit: 'test/unit',
@@ -17,9 +23,11 @@ let baseConfig = {
1723
]
1824
},
1925
file: {
20-
favicon: 'favicon.png',
21-
karmaConf: 'karma.conf.babel.js',
22-
nightWatch: 'nightwatch.json'
26+
favicon: 'favicon.png'
27+
},
28+
dev: {
29+
host: '127.0.0.1',
30+
port: 5000
2331
}
2432
};
2533

config/dev.config.js

-28
This file was deleted.

config/prod.config.js

-14
This file was deleted.

config/util/path-util.js

-19
This file was deleted.

config/utils/path-util.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import path from 'path';
2+
3+
function resolve(dir) {
4+
return path.join(__dirname, '../..', dir);
5+
}
6+
7+
export default {
8+
resolve
9+
};

config/util/vue-loader-util.js config/utils/vue-loader-util.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Created by CUIJA on 04-17-2017.*/
21
import _ from 'lodash';
32

43
import ExtractTextPlugin from 'extract-text-webpack-plugin';
@@ -41,6 +40,9 @@ function buildVueStylesLoader(options) {
4140
css: generateStylesLoader(null, options),
4241
postcss: generateStylesLoader(null, options),
4342
less: generateStylesLoader('less', options),
43+
sass: generateStylesLoader('sass', options, {indentedSyntax: true}),
44+
scss: generateStylesLoader('sass', options),
45+
stylus: generateStylesLoader('stylus', options),
4446
styl: generateStylesLoader('stylus', options)
4547
}
4648
};
@@ -52,7 +54,7 @@ function buildVueStylesLoader(options) {
5254
* @param {Object} extraOptions
5355
* */
5456
function generateStylesLoader(loaderNamePrefix, loaderOptions, extraOptions) {
55-
let { sourceMap, extract, minimize } = loaderOptions;
57+
let {sourceMap, extract, minimize} = loaderOptions;
5658
sourceMap = _.isUndefined(sourceMap) ? true : sourceMap;
5759
extract = _.isUndefined(extract) ? false : extract;
5860
minimize = _.isUndefined(sourceMap) ? false : minimize;

config/webpack.base.config.babel.js config/webpack.base.babel.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
/* Created by Aquariuslt on 14/04/2017.*/
22

3-
import HtmlWebpackPlugin from 'html-webpack-plugin';
43
import ExtractTextPlugin from 'extract-text-webpack-plugin';
54

6-
import pathUtil from './util/path-util';
5+
import pathUtil from './utils/path-util';
76
import baseConfig from './base.config';
87

98
let webpackBaseConfig = {
109
entry: {
11-
main: './src/main.js',
12-
styles: './src/styles.css'
10+
main: pathUtil.resolve(baseConfig.dir.src) + '/' + 'main.js'
1311
},
1412
resolve: {
1513
extensions: [
@@ -26,15 +24,23 @@ let webpackBaseConfig = {
2624
{
2725
test: /\.js$/,
2826
include: [
29-
pathUtil.root(baseConfig.dir.src),
30-
pathUtil.root(baseConfig.dir.test.unit),
31-
pathUtil.root(baseConfig.dir.test.e2e)
27+
pathUtil.resolve(baseConfig.dir.src),
28+
pathUtil.resolve(baseConfig.dir.test.unit),
29+
pathUtil.resolve(baseConfig.dir.test.e2e)
3230
],
3331
loader: 'babel-loader'
3432
},
33+
{
34+
test: /\.less$/,
35+
include: pathUtil.resolve('src'),
36+
loader: ExtractTextPlugin.extract({
37+
use: ['css-loader', 'less-loader'],
38+
fallback: ['style-loader']
39+
})
40+
},
3541
{
3642
test: /\.css$/,
37-
include: pathUtil.root(baseConfig.dir.src),
43+
include: pathUtil.resolve(baseConfig.dir.src),
3844
loader: ExtractTextPlugin.extract({
3945
use: ['css-loader'],
4046
fallback: ['style-loader']
@@ -60,13 +66,7 @@ let webpackBaseConfig = {
6066
}
6167
}
6268
]
63-
},
64-
plugins: [
65-
new HtmlWebpackPlugin({
66-
template: `./${baseConfig.dir.src}/index.html`,
67-
favicon: `./${baseConfig.dir.src}/${baseConfig.file.favicon}`
68-
})
69-
]
69+
}
7070
};
7171

7272
export default webpackBaseConfig;

config/webpack.dev.config.babel.js config/webpack.dev.babel.js

+23-28
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
/* Created by Aquariuslt on 14/04/2017.*/
22
import webpack from 'webpack';
33
import merge from 'webpack-merge';
4-
import webpackBaseConfig from './webpack.base.config.babel';
4+
import webpackBaseConfig from './webpack.base.babel';
55

6+
import HtmlWebpackPlugin from 'html-webpack-plugin';
67
import ExtractTextPlugin from 'extract-text-webpack-plugin';
78
import FriendlyErrorsPlugin from 'friendly-errors-webpack-plugin';
9+
import VueLoaderPlugin from 'vue-loader/lib/plugin';
10+
11+
import vueLoaderUtil from './utils/vue-loader-util';
12+
import pathUtil from './utils/path-util';
13+
14+
import baseConfig from './base.config';
15+
16+
const PROTOCOL = 'http://';
17+
818

9-
import devConfig from './dev.config';
10-
import vueLoaderUtil from './util/vue-loader-util';
11-
import pathUtil from './util/path-util';
1219

1320
let webpackDevConfig = merge(webpackBaseConfig, {
21+
mode: 'development',
1422
devtool: 'eval-source-map',
1523
output: {
16-
path: devConfig.output.path,
17-
publicPath: devConfig.output.publicPath,
24+
path: pathUtil.resolve(baseConfig.dir.build),
25+
publicPath: PROTOCOL + baseConfig.dev.host + ':' + baseConfig.dev.port,
1826
filename: '[name].bundle.js',
1927
sourceMapFilename: '[name].bundle.js.map',
2028
chunkFilename: '[id].chunk.js'
@@ -33,33 +41,20 @@ let webpackDevConfig = merge(webpackBaseConfig, {
3341
]
3442
},
3543
plugins: [
36-
new webpack.DefinePlugin({
37-
'process.env': {
38-
NODE_ENV: '"development"'
39-
}
40-
}),
41-
new webpack.optimize.CommonsChunkPlugin({
42-
name: 'vendor',
43-
minChunks: function (module) {
44-
return (
45-
module.resource &&
46-
/\.js$/.test(module.resource) &&
47-
module.resource.indexOf(
48-
pathUtil.root('node_modules')
49-
) === 0
50-
);
51-
}
52-
}),
5344
new ExtractTextPlugin({
5445
filename: '[name].bundle.css'
5546
}),
47+
new HtmlWebpackPlugin({
48+
template: baseConfig.dir.src + '/index.html',
49+
favicon: baseConfig.dir.src + '/' + baseConfig.file.favicon
50+
}),
5651
new webpack.HotModuleReplacementPlugin(),
57-
new webpack.NoEmitOnErrorsPlugin(),
58-
new FriendlyErrorsPlugin()
52+
new FriendlyErrorsPlugin(),
53+
new VueLoaderPlugin()
5954
],
6055
devServer: {
61-
host: devConfig.devServer.host,
62-
port: devConfig.devServer.port,
56+
host: baseConfig.dev.host,
57+
port: baseConfig.dev.port,
6358
historyApiFallback: true,
6459
quiet: false,
6560
noInfo: true,
@@ -74,7 +69,7 @@ let webpackDevConfig = merge(webpackBaseConfig, {
7469
chunks: true,
7570
chunkModules: false
7671
},
77-
publicPath: devConfig.output.publicPath
72+
publicPath: PROTOCOL + baseConfig.dev.host + ':' + baseConfig.dev.port,
7873
}
7974
});
8075

0 commit comments

Comments
 (0)