我们有一个文件需要在运行时在服务器端呈现玉石模板。
define(['underscore', 'html!/templates/myTemplate'], function (_, template){
...
})
这个想法是在编译时捆绑其他依赖项(这里是下划线),但只在运行时需要模板。
我们尝试使用这样的外部,但它没有改变任何东西。
externals: {
'/templates/myTemplate': '/templates/myTemplate'
}
但是编译捆绑包时会显示相同的错误:
Module not found: Error: Cannot resolve 'file' or 'directory' /templates/myTemplate ...
有什么想法吗?
这是我们的设置文件
module.exports = {
context: __dirname,
entry: {
"pageA": "./pageA.js",
"pageB": "./pageB.js"
},
output: {
"path": __dirname + '/dist',
"publicPath": './javascripts/dist/',
"filename": '[name].js'
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
]
};