Skip to content

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