Skip to content
This repository was archived by the owner on May 14, 2023. It is now read-only.

Commit ad43fdd

Browse files
committed
Fixed problems with babel and es6.
1 parent baa6721 commit ad43fdd

13 files changed

+139
-19
lines changed

. babelrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["env"],
3+
"plugins": ["transform-runtime"]
4+
}
File renamed without changes.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.idea/
22
node_modules/
3-
dist/
43
**/*.log

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"autoprefixer": "^6.7.7",
3030
"babel-core": "^6.24.1",
3131
"babel-loader": "^6.4.1",
32-
"babel-preset-es2015": "^6.24.1",
32+
"babel-plugin-transform-runtime": "^6.23.0",
33+
"babel-preset-env": "^1.4.0",
3334
"browser-sync": "^2.18.8",
3435
"css-loader": "^0.28.0",
3536
"eslint": "^3.19.0",

server/build.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
process.env.NODE_ENV = 'production';
2+
3+
const webpack = require('webpack');
4+
const webpackConfig = require('./webpack.config.prod');
5+
6+
webpack(webpackConfig, (err, stats) => {
7+
if(err || stats.hasErrors()) {
8+
console.error(stats);
9+
return 0;
10+
}
11+
12+
console.log('DONE!');
13+
});

server/webpack.config.prod.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const path = require('path');
2+
const webpackModules = require('./webpack.modules.prod');
3+
const webpackPlugins = require('./webpack.plugins.prod');
4+
5+
const config = {
6+
entry: './src/index.js',
7+
output: {
8+
filename: '[name].[hash].js',
9+
path: path.resolve(__dirname, '../dist'),
10+
},
11+
target: 'web',
12+
module: webpackModules,
13+
plugins: webpackPlugins,
14+
};
15+
16+
module.exports = config;

server/webpack.modules.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ module.exports = {
1717
},
1818
{
1919
test: /\.vue$/,
20-
exclude: [
21-
path.resolve(__dirname, '../node_modules'),
20+
exclude: /node_modules/,
21+
use: [
22+
{ loader: 'vue-loader' },
2223
],
23-
use: 'vue-loader',
2424
},
2525
{
2626
test: /\.js$/,
27-
exclude: [
28-
path.resolve(__dirname, '../node_modules'),
29-
],
27+
exclude: /node_modules/,
3028
use: [
3129
{ loader: 'babel-loader' },
3230
],

server/webpack.modules.prod.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
3+
const path = require('path');
4+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
6+
module.exports = {
7+
rules: [
8+
{
9+
test: /\.(js|vue)$/,
10+
exclude: [
11+
path.resolve(__dirname, '../node_modules'),
12+
],
13+
use: [
14+
{ loader: 'eslint-loader', options: { failOnError: true } },
15+
],
16+
enforce: 'pre',
17+
},
18+
{
19+
test: /\.vue$/,
20+
exclude: [
21+
path.resolve(__dirname, '../node_modules'),
22+
],
23+
use: 'vue-loader',
24+
},
25+
{
26+
test: /\.js$/,
27+
exclude: [
28+
path.resolve(__dirname, '../node_modules'),
29+
],
30+
use: [
31+
{ loader: 'babel-loader' },
32+
],
33+
},
34+
{
35+
test: /\.scss$/,
36+
exclude: [
37+
path.resolve(__dirname, '../node_modules'),
38+
],
39+
use: ExtractTextPlugin.extract({
40+
fallback: 'style-loader',
41+
use: [
42+
{ loader: 'css-loader', options: { minimize: true } },
43+
{ loader: 'resolve-url-loader' },
44+
{ loader: 'sass-loader?sourceMap' },
45+
{ loader: 'postcss-loader' },
46+
],
47+
}),
48+
},
49+
{
50+
test: /\.(woff|woff2)$/,
51+
use: [
52+
{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]' } },
53+
],
54+
},
55+
{
56+
test: /\.(gif|jpg|png)$/,
57+
use: [
58+
{ loader: 'url-loader', options: { name: 'images/[name].[ext]?[hash]', limit: 5000 } },
59+
],
60+
},
61+
{
62+
test: /\.svg$/,
63+
use: [
64+
{ loader: 'file-loader', options: { name: 'images/[name].[ext]?[hash]' } },
65+
],
66+
},
67+
],
68+
};

server/webpack.plugins.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const webpack = require('webpack');
44
const HtmlWebpackPlugin = require('html-webpack-plugin');
55
const ExtractTextPlugin = require('extract-text-webpack-plugin');
66

7-
const COPYRIGHT_TEXT = 'Copyright 2017\nCode by Jeff Mosawy\n\nhttp://www.jmosawy.com\nj@mosawy.net';
8-
97
module.exports = [
108
new webpack.optimize.CommonsChunkPlugin({
119
name: 'vendor',
@@ -23,5 +21,4 @@ module.exports = [
2321
}),
2422
new webpack.HotModuleReplacementPlugin(),
2523
new ExtractTextPlugin('app.css?[contenthash]'),
26-
new webpack.BannerPlugin({ banner: COPYRIGHT_TEXT }),
2724
];

server/webpack.plugins.prod.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
3+
const webpack = require('webpack');
4+
const HtmlWebpackPlugin = require('html-webpack-plugin');
5+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
6+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
7+
8+
const COPYRIGHT_TEXT = 'Copyright 2017\nCode by Jeff Mosawy\n\nhttp://www.jmosawy.com\nj@mosawy.net';
9+
10+
module.exports = [
11+
new webpack.optimize.CommonsChunkPlugin({
12+
name: 'vendor',
13+
minChunks(module) {
14+
return module.context && module.context.indexOf('node_modules') !== -1;
15+
},
16+
}),
17+
new webpack.optimize.CommonsChunkPlugin({
18+
name: 'manifest',
19+
}),
20+
new HtmlWebpackPlugin({
21+
filename: 'index.html',
22+
template: 'index.html',
23+
inject: true,
24+
}),
25+
new UglifyJsPlugin(),
26+
new ExtractTextPlugin('app.css?[contenthash]'),
27+
new webpack.BannerPlugin({ banner: COPYRIGHT_TEXT }),
28+
new webpack.DefinePlugin({
29+
'process.env.NODE_ENV': JSON.stringify('production')
30+
}),
31+
];

src/pages/Home.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<script>
2525
/* eslint-disable object-shorthand */
2626
/* eslint-disable arrow-body-style */
27-
/* eslint-disable no-console */
2827
2928
import Clipboard from 'clipboard';
3029
@@ -63,7 +62,6 @@
6362
},
6463
methods: {
6564
filterSearch: function (val) {
66-
console.log(val);
6765
this.searchedTerm = val;
6866
},
6967
},

src/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
@import "styles/core/all";
12
@import "styles/tools/mixins";
23
@import "styles/tools/transitions";
3-
@import "styles/core/all";
44

55
@import "styles/modules/grid";
66

0 commit comments

Comments
 (0)