参考文档:http://www.cnblogs.com/tugenhua0707/p/5576262.html#_labe0
1: 只需在配置文件中加入:
resolve: { extensions: ['', '.js', '.jsx'],
//模块别名定义,方便后续直接引用别名,无须多写长长的地址
alias: {
a : 'js/assets/a.js', // 后面直接引用 require(“a”)即可引用到模块
b : 'js/assets/b.js',
c : 'js/assets/c.js'
}
}
2:publicPath的用途:
output: {
filename: "[name].js",
path:path.resolve(__dirname,"build")
}
如果没有指定pubicPath,则引入路径如下
<body>
<script src="b.js"></script>
</body>
如果有指定publicPath
output: {
filename: "[name].js",
path:path.resolve(__dirname,"build"),
publicPath:"/assets/"
}
则引入如下
<body>
<script src="assets/b.js"></script>
</body>