如何给path属性设置绝对路径?
因为我们现在用的webpack是新的版本了,你把path改成publicPath就可以了
const path = require('path');
module.exports = {
entry: "./src/script/main.js",
output: {
path: path.resolve(__dirname, "dist/js'"),
filename: 'bundle.js'
}
}
亲测可以,共勉
因为教程里的webpack 版本较低, 配置方式已经有些不一样了, 新版需要如下编写:
var fileDir = __dirname;
var path = require('path');
module.exports = {
entry: './src/script/main.js',
output: {
path: path.resolve(fileDir, './dist'),
filename:xxx
}