Skip to content

Commit

Permalink
build: webpack 路径别名配置
Browse files Browse the repository at this point in the history
  • Loading branch information
MoYuanJun committed Jul 25, 2019
1 parent 7ec9494 commit f8cf53e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const path = require('path');
const webpack = require('webpack');

// 路径别名
const alias = {};
const alias = {
"@components": path.resolve(__dirname, '../components'),
"@pages": path.resolve(__dirname, '../stories/pages'),
};

module.exports = {
mode: 'production',
Expand Down
14 changes: 14 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"@pages/*": ["stories/pages/*"],
"@components/*": ["components/*"]
},
"target": "ES6",
"module": "es6",
"allowSyntheticDefaultImports": true
},
"exclude": ["node_modules"]
}
5 changes: 3 additions & 2 deletions stories/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Introduce from './pages/base/Introduce';
import scrollbar from './pages/container/Scrollbar';
import Introduce from '@pages/base/Introduce';
import scrollbar from '@pages/container/Scrollbar';

export default [
{
title: '介绍',
Expand Down
4 changes: 2 additions & 2 deletions stories/pages/container/Scrollbar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Scrollbar } from '../../../../components';
import '../../../../components/scrollbar/style';
import { Scrollbar } from '@components';
import '@components/scrollbar/style';

export default () => {
return (
Expand Down

0 comments on commit f8cf53e

Please sign in to comment.