Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
riophae committed Aug 4, 2018
1 parent 5db1f9f commit 90104ed
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 48 deletions.
16 changes: 0 additions & 16 deletions .babelrc

This file was deleted.

17 changes: 17 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = api => {
api.cache.using(() => process.env.NODE_ENV)

const presets = [
[ '@babel/preset-env', { modules: false } ],
]
const plugins = [
'transform-vue-jsx',
'@babel/plugin-transform-runtime',
]

if (process.env.NODE_ENV === 'testing') {
plugins.push('istanbul')
}

return { presets, plugins, comments: false }
}
15 changes: 15 additions & 0 deletions build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@ const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const config = require('../config')

const resolve = exports.resolve = dir => {
return path.join(__dirname, '..', dir)
}

exports.assetsPath = _path => {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.docs.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}

exports.eslintLoader = dir => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [ resolve(dir) ],
options: {
formatter: require('eslint-friendly-formatter'),
cache: true,
},
})

exports.styleLoaders = (options = {}) => {
const loaders = [ 'cache-loader', {
loader: 'css-loader',
Expand Down
29 changes: 7 additions & 22 deletions build/webpack.base.conf.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
const path = require('path')
const webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader')
const config = require('../config')
const { withCacheLoader } = require('./utils')

function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const utils = require('./utils')

module.exports = {
entry: {
Expand All @@ -26,23 +21,14 @@ module.exports = {
// see: https://vuejs.org/v2/guide/installation.html#Explanation-of-Different-Builds
vue$: 'vue/dist/vue',
// for consistent docs
'@riophae/vue-treeselect': resolve('src'),
'@riophae/vue-treeselect': utils.resolve('src'),
// for shorter import path in tests
'@src': resolve('src'),
'@src': utils.resolve('src'),
},
},
module: {
rules: [
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [ resolve('src'), resolve('test') ],
options: {
formatter: require('eslint-friendly-formatter'),
},
},
withCacheLoader({
utils.withCacheLoader({
test: /\.vue$/,
loader: 'vue-loader',
options: {
Expand All @@ -51,17 +37,16 @@ module.exports = {
},
},
}),
withCacheLoader({
utils.withCacheLoader({
test: /\.js$/,
loader: 'babel-loader',
include: [ resolve('src'), resolve('docs'), resolve('test') ],
include: [ 'src', 'docs', 'test' ].map(utils.resolve),
}, {
disableCacheInTest: true,
}),
withCacheLoader({
utils.withCacheLoader({
test: /\.pug$/,
loader: 'pug-loader',
include: [ resolve('src'), resolve('docs') ],
options: {
pretty: true,
},
Expand Down
1 change: 1 addition & 0 deletions build/webpack.dev.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = merge(baseWebpackConfig, {
mode: 'development',
module: {
rules: [
utils.eslintLoader('src'),
utils.styleLoaders({
sourceMap: config.dev.cssSourceMap,
}),
Expand Down
3 changes: 2 additions & 1 deletion build/webpack.test.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ if (!process.env.NODE_ENV) {

const webpack = require('webpack')
const merge = require('webpack-merge')
const utils = require('./utils')
const baseConfig = require('./webpack.base.conf')
const utils = require('./utils')

const webpackConfig = merge(baseConfig, {
mode: 'development',
module: {
rules: [
utils.eslintLoader('test'),
utils.styleLoaders(),
],
},
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"dev": "node build/dev-server.js",
"bundle": "node build/bundle.js",
"docs": "rimraf gh-pages && mkdir gh-pages && node build/build.js",
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --watch",
"unit": "karma start test/unit/karma.conf.js --watch",
"gh-pages": "npm run docs && gh-pages --dist gh-pages --branch gh-pages --dotfiles",
"testonly": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"testonly": "karma start test/unit/karma.conf.js --single-run",
"test": "npm run testonly",
"pretest": "npm run lint",
"lint:js": "eslint --ext .js --ext .vue --cache --rule 'no-console: 2' .",
"lint:js": "eslint --ext .js --ext .vue --cache --cache-location node_modules/.cache/eslint --rule 'no-console: 2' .",
"lint:css": "stylelint '**/*.less'",
"lint": "npm run lint:js && npm run lint:css",
"size": "size-limit",
Expand All @@ -30,6 +30,7 @@
},
"pre-commit": "lint",
"dependencies": {
"@babel/runtime": "^7.0.0-beta.56",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"easings-css": "^1.0.0",
"fuzzysearch": "^1.0.3",
Expand All @@ -39,11 +40,10 @@
"watch-size": "^2.0.0"
},
"devDependencies": {
"@babel/core": "^7.0.0-beta.51",
"@babel/plugin-syntax-jsx": "^7.0.0-beta.53",
"@babel/plugin-transform-runtime": "^7.0.0-beta.51",
"@babel/preset-env": "^7.0.0-beta.51",
"@babel/runtime": "^7.0.0-beta.51",
"@babel/core": "^7.0.0-beta.56",
"@babel/plugin-syntax-jsx": "^7.0.0-beta.56",
"@babel/plugin-transform-runtime": "^7.0.0-beta.56",
"@babel/preset-env": "^7.0.0-beta.56",
"@vue/test-utils": "1.0.0-beta.16",
"autoprefixer": "^9.0.0",
"babel-eslint": "^8.2.5",
Expand All @@ -55,7 +55,6 @@
"codecov": "^3.0.0",
"connect-history-api-fallback": "^1.5.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.1.4",
"css-loader": "^1.0.0",
"entities": "^1.1.1",
"eslint": "^5.1.0",
Expand Down

0 comments on commit 90104ed

Please sign in to comment.