|
楼主 |
2020-12-28 11:12:59
显示全部楼层
配置代码
module.exports = {
webpack: {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
components: path.resolve(__dirname, 'src/components'),
},
},
plugins: [
// 自动替换代码中的变量
new webpack.DefinePlugin({
ORIGIN: 'https://test.com',
}),
],
},
};
测试页面代码
console.log('ORIGIN', ORIGIN);
结果
Uncaught SyntaxError: missing ) after argument list
at Object../src/pages/test-page3/index.js (index.js:370)
at __webpack_require__ (index.js:23)
at __scriptModule__ (index.ux?0375:16)
at eval (index.ux?e573:8)
at Ki (web.js:1)
at web.js:1
at r (web.js:1)
at eval (index.ux?e573:7)
at Object../src/pages/test-page3/index.ux?uxType=page (index.js:381)
at __webpack_require__ (index.js:23)
electron/js2c/renderer_init.js:114 Uncaught TypeError: r.process.listenerCount is not a function
at window.onerror (electron/js2c/renderer_init.js:114) |
|