bbddl 2019-07-01
参考来源:
https://stackoverflow.com/que...
webpack配置,将index.js变为index.ejs模板
const HtmlWebpackPlugin = require('html-webpack-plugin') module.exports = { entry: 'index.js', output: { path: __dirname + '/dist', filename: 'index_bundle.js' }, plugins: [ new HtmlWebpackPlugin({ filename: __dirname + '/dist/index.ejs', }) ] }
webpack的入口文件(index.js)添加
__webpack_nonce__ = '<%=nonce%>';
服务端程序,遇到index.js的请求,就替换掉<%=nonce%>