Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加script src对于webpack别名的支持 #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HadiChen
Copy link

No description provided.

@anchengjian
Copy link
Member

怎么使用这个 feature ,能给点说明?

@HadiChen
Copy link
Author

是用来识别script标签中的src,假如有使用webpack中已经配置的别名则使用别名中的路径,之前script的src一直要使用相对路径:

<script src="../assets/js/test.js"></script>

现在只要配置好别名就可以使用别名:

// webpack.base.conf.js

function resolve (dir) {
  return path.join(__dirname, '..', dir)
}

module.exports = {
     resolve: {
         alias: {
            '@': resolve('src'),
            '~': resolve('src'),
            'js': resolve('src/assets/js'),
            vue: 'mpvue'
         }
     }
}
<script src="js/test.js"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants