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

webpack打包之后静态资源引用路径不对 #34

Closed
bosens-China opened this issue Dec 4, 2018 · 3 comments
Closed

webpack打包之后静态资源引用路径不对 #34

bosens-China opened this issue Dec 4, 2018 · 3 comments

Comments

@bosens-China
Copy link

webpack的配置文件
build: {
index: path.resolve(__dirname, '../ROOT/index.html'),
assetsRoot: path.resolve(__dirname, '../ROOT'),
// index: path.resolve(__dirname, '../plat/index.html'),
// assetsRoot: path.resolve(__dirname, '../plat'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
productionSourceMap: false,
devtool: '#source-map',
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
bundleAnalyzerReport: process.env.npm_config_report
}
这里我希望引用的静态资源带有打包文件的路径,但是没有出现
浏览器查找的路径
E:/static/UEditor/ueditor.config.js
真实的路径
E:\workspace\open-system\open-system\static

@haochuan9421
Copy link
Owner

你是不把 assetsPublicPath: '/' 改成了 assetsPublicPath: './' 而且项目没有部署在网站的根目录下?如果是那样的话,你填 UEDITOR_HOME_URL: './static/UEditor/' 试一试

@bosens-China
Copy link
Author

不的英文把你assetsPublicPath: '/' 改成了assetsPublicPath: './'而且在项目没有部署网站的根目录下?如果是那样的话,你填UEDITOR_HOME_URL: './static/UEditor/'试一试

谢谢,已经解决了问题,不过我很困惑,为什么之前没有出现这样的情况,这样短暂的解决问题不知道部署到网站上会不会出现新的问题,不过还是非常感谢你

@haochuan9421
Copy link
Owner

@bosens-China 相当路径,绝对路径,webpack构建等等都了解一下,而且见过不少人因为路由使用 history 模式又设置了相对路径而出错的,总之这个要具体问题具体分析。有些特殊情况也可能需要用到process.env.NODE_ENV 区分设置,我在 README 里也都提过

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

No branches or pull requests

2 participants