Skip to content

Commit

Permalink
fix: find node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
deot committed Apr 9, 2020
1 parent 1b43d12 commit 52dc585
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions node/config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
const path = require('path');
const fs = require('fs-extra');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const merge = require('webpack-merge');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');

const { resolve } = path;
const r = (source) => resolve(__dirname, '../node_modules', source);
const cwd = process.cwd();

const r = (source) => {
let fullpath;

fullpath = resolve(__dirname, '../node_modules', source);
if (fs.pathExistsSync(fullpath)) {
return fullpath;
}

fullpath = resolve(cwd, './node_modules', source);
if (fs.pathExistsSync(fullpath)) {
return fullpath;
}

throw new Error(`@wya/doc: 未找到${source}`);
};

class Config {
constructor(type, parent) {

Expand Down Expand Up @@ -83,7 +101,7 @@ class Config {
// exclude: /node_modules/,
exclude,
use: {
loader: 'babel-loader',
loader: r('babel-loader'),
options: {
// 不使用sourceDir本地配置
babelrc: false,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wya/doc",
"version": "1.1.0",
"version": "1.1.1",
"description": "wya-doc for js",
"main": "index.js",
"files": [
Expand Down

0 comments on commit 52dc585

Please sign in to comment.