Skip to content

Commit ab5787e

Browse files
chore: Update test environment (#66)
* Adapt webpack config for build to the updated environment * Adapts webpack.dev config with the updated environment * Adapt webpack for "docs" build * clean up not necessaries dependencies and scripts * Updates dependencies + use jest for test
1 parent 8900d84 commit ab5787e

34 files changed

+7062
-5647
lines changed

.babelrc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{
2-
"presets": [
3-
["env", { "modules": false }],
4-
"stage-2"
5-
],
6-
"plugins": ["transform-runtime", "transform-es2015-modules-commonjs"],
7-
"comments": false,
2+
"presets": ["@babel/preset-env"],
83
"env": {
94
"test": {
10-
"presets": ["env", "stage-2"],
11-
"plugins": [ "istanbul" ]
5+
"presets": [
6+
["@babel/preset-env", { "targets": { "node": "current" }}]
7+
]
128
}
139
}
1410
}

.eslintrc.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
module.exports = {
44
root: true,
5-
parser: 'babel-eslint',
65
parserOptions: {
6+
parser: 'babel-eslint',
77
sourceType: 'module'
88
},
99
env: {
1010
browser: true,
1111
},
1212
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
13-
extends: 'standard',
13+
extends: ['eslint:recommended', "plugin:vue/essential"],
1414
// required to lint *.vue files
1515
plugins: [
1616
'html'
@@ -21,7 +21,20 @@ module.exports = {
2121
'arrow-parens': 0,
2222
// allow async-await
2323
'generator-star-spacing': 0,
24+
// no semicolon
25+
'semi': 0,
2426
// allow debugger during development
2527
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26-
}
28+
},
29+
"overrides": [{
30+
"files": [
31+
"**/*.spec.js",
32+
"**/*.spec.jsx",
33+
"**/__tests__/*.{j,t}s?(x)",
34+
"**/test/unit/**/*.spec.{j,t}s?(x)"
35+
],
36+
"env": {
37+
"jest": true
38+
}
39+
}]
2740
}

.jshintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"esversion": 8
3+
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
language: node_js
22
node_js:
3-
- "6"
3+
- "12.16"

build/build.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,5 @@ rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
2727
}) + '\n\n')
2828

2929
console.log(chalk.cyan(' Build complete.\n'))
30-
console.log(chalk.yellow(
31-
' Tip: built files are meant to be served over an HTTP server.\n' +
32-
' Opening index.html over file:// won\'t work.\n'
33-
))
3430
})
3531
})

build/utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ exports.cssLoaders = function (options) {
1515
var cssLoader = {
1616
loader: 'css-loader',
1717
options: {
18-
minimize: process.env.NODE_ENV === 'production',
1918
sourceMap: options.sourceMap
2019
}
2120
}

build/webpack.base.conf.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var path = require('path')
22
var utils = require('./utils')
33
var config = require('../config')
44
var vueLoaderConfig = require('./vue-loader.conf')
5+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
56

67
function resolve (dir) {
78
return path.join(__dirname, '..', dir)
@@ -62,5 +63,8 @@ module.exports = {
6263
}
6364
}
6465
]
65-
}
66+
},
67+
plugins: [
68+
new VueLoaderPlugin()
69+
]
6670
}

build/webpack.dev.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Object.keys(baseWebpackConfig.entry).forEach(function (name) {
1212
})
1313

1414
module.exports = merge(baseWebpackConfig, {
15+
mode: 'development',
1516
module: {
1617
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
1718
},

build/webpack.prod.conf.js

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,42 @@ var CopyWebpackPlugin = require('copy-webpack-plugin')
88
var HtmlWebpackPlugin = require('html-webpack-plugin')
99
var ExtractTextPlugin = require('extract-text-webpack-plugin')
1010
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
11+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
1112

1213
var env = process.env.NODE_ENV === 'testing'
1314
? require('../config/test.env')
1415
: config.build.env
1516

1617
var webpackConfig = merge(baseWebpackConfig, {
18+
mode: "production",
19+
optimization: {
20+
minimizer: [
21+
new UglifyJsPlugin({
22+
sourceMap: true,
23+
uglifyOptions: {
24+
warnings: false
25+
}
26+
})
27+
],
28+
splitChunks: {
29+
name: false,
30+
cacheGroups: {
31+
vendor: {
32+
chunks: "initial",
33+
test: path.resolve(__dirname, "../node_modules"),
34+
name: "vendor",
35+
enforce: true
36+
}
37+
}
38+
}
39+
},
1740
module: {
1841
rules: utils.styleLoaders({
1942
sourceMap: config.build.productionSourceMap,
2043
extract: true
2144
})
2245
},
23-
devtool: config.build.productionSourceMap ? '#source-map' : false,
46+
devtool: config.build.productionSourceMap ? 'source-map' : false,
2447
output: {
2548
path: config.build.assetsRoot,
2649
filename: utils.assetsPath('js/[name].[chunkhash].js'),
@@ -31,15 +54,9 @@ var webpackConfig = merge(baseWebpackConfig, {
3154
new webpack.DefinePlugin({
3255
'process.env': env
3356
}),
34-
new webpack.optimize.UglifyJsPlugin({
35-
compress: {
36-
warnings: false
37-
},
38-
sourceMap: true
39-
}),
4057
// extract css into its own file
4158
new ExtractTextPlugin({
42-
filename: utils.assetsPath('css/[name].[contenthash].css')
59+
filename: utils.assetsPath('css/[name].[hash].css')
4360
}),
4461
// Compress extracted CSS. We are using this plugin so that possible
4562
// duplicated CSS from different components can be deduped.
@@ -63,26 +80,6 @@ var webpackConfig = merge(baseWebpackConfig, {
6380
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
6481
chunksSortMode: 'dependency'
6582
}),
66-
// split vendor js into its own file
67-
new webpack.optimize.CommonsChunkPlugin({
68-
name: 'vendor',
69-
minChunks: function (module, count) {
70-
// any required modules inside node_modules are extracted to vendor
71-
return (
72-
module.resource &&
73-
/\.js$/.test(module.resource) &&
74-
module.resource.indexOf(
75-
path.join(__dirname, '../node_modules')
76-
) === 0
77-
)
78-
}
79-
}),
80-
// extract webpack runtime and module manifest to its own file in order to
81-
// prevent vendor hash from being updated whenever app bundle is updated
82-
new webpack.optimize.CommonsChunkPlugin({
83-
name: 'manifest',
84-
chunks: ['vendor']
85-
}),
8683
// copy custom static assets
8784
new CopyWebpackPlugin([
8885
{

build/webpack.release.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ const path = require('path');
44
const webpack = require('webpack');
55
const npmCfg = require('../package.json');
66
const projectRoot = path.resolve(__dirname, '../');
7-
var vueLoaderConfig = require('./vue-loader.conf')
7+
var vueLoaderConfig = require('./vue-loader.conf');
8+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
9+
var utils = require('./utils');
10+
var config = require('../config')
811

912
function resolve (dir) {
1013
return path.join(__dirname, '..', dir)
@@ -17,6 +20,10 @@ var banner = [
1720
].join('\n')
1821

1922
module.exports = {
23+
mode: "production",
24+
optimization: {
25+
minimize: false,
26+
},
2027
entry: './src/components/CookieLaw.vue',
2128
output: {
2229
path: path.resolve(__dirname, '../dist'),
@@ -41,17 +48,21 @@ module.exports = {
4148
loader: 'babel-loader',
4249
options: {
4350
presets: [
44-
['es2015', { modules: false }]
51+
['@babel/preset-env', { modules: false }]
4552
],
46-
'plugins': ['transform-runtime', 'transform-es2015-modules-commonjs'],
4753
}
4854
}],
4955
include: [resolve('src'), resolve('test')]
56+
},
57+
{
58+
test: /\.scss$/,
59+
use: [require.resolve('vue-style-loader'), require.resolve('css-loader'), require.resolve('sass-loader')],
5060
}
5161
]
5262
},
5363

5464
plugins: [
55-
new webpack.BannerPlugin(banner)
65+
new webpack.BannerPlugin(banner),
66+
new VueLoaderPlugin()
5667
]
5768
}

build/webpack.release.min.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
55

66
delete config.devtool
77

8-
config.plugins = [
9-
new webpack.optimize.UglifyJsPlugin({
10-
sourceMap: false,
11-
compress: {
12-
warnings: false
13-
}
14-
}),
15-
new webpack.optimize.OccurenceOrderPlugin()
16-
]
8+
config.optimization.minimize = true
179

1810
module.exports = config

config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
index: path.resolve(__dirname, '../docs/index.html'),
88
assetsRoot: path.resolve(__dirname, '../docs'),
99
assetsSubDirectory: 'static',
10-
assetsPublicPath: '/',
10+
assetsPublicPath: '',
1111
productionSourceMap: false,
1212
// Gzip off by default as many popular static hosts such as
1313
// Surge or Netlify already gzip all static assets for you.

config/rollup-plugin-vue.config.js

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

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta charset=utf-8><title>vue-cookie-law</title><link href=static/css/app.2ec6e1d8d318f43886803c2d71ae454f.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/manifest.741921c978d2c38ec9c9.js></script><script type=text/javascript src=static/js/vendor.281da864b3eb29cff916.js></script><script type=text/javascript src=static/js/app.57a154c8adaa56de266d.js></script></body></html>
1+
<!DOCTYPE html><html><head><meta charset=utf-8><title>vue-cookie-law</title><link href=static/css/app.38cda54e5f033778fc20.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/1.009fefe989afe4a788ac.js></script><script type=text/javascript src=static/js/app.0db0c7860a093918af1a.js></script></body></html>

docs/static/css/app.2ec6e1d8d318f43886803c2d71ae454f.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/static/css/app.2ec6e1d8d318f43886803c2d71ae454f.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)