2017-04-06 26 views
0

我想使用Webpack,以便我可以將HTML注入到屬性文件中(請勿關於如何不安全的講座:-))我嘗試使用以下配置...我可以有webpack輸出是一個字符串,而不是JS

var webpack = require("webpack"); 
var path = require("path"); 
module.exports = { 
    context:"", 
    entry: { 
    projects: path.join(__dirname, "../other/src/properties") 
    }, 
    resolve: { 
    extensions: [ 
     '.pre.properties', 
     '.html', 
     '.htm' 
    ] 
    }, 
    output: { 
    filename: "[name].properties", 
    path: path.join(__dirname, "../other/src") 
    }, 
    module: { 
    rules: [ 
     { 
     test: /\.html$/, 
     use: ["to-string-loader", "html-loader?interpolate=require&-minimize"] 
     }, 
     { 
     test: /\.properties$/, 
     use: ["raw-loader"] 
     } 
    ] 
    } 
}; 

問題是它仍然在JS中包裝所有東西,而不是原始字符串。我可以將Webpack作爲原始字符串輸出嗎?

回答

0

由於我使用的WebPack 2我可以創建一個包裝JS這樣的...

var a = require("./projects.pre.properties"); 

然後我配置了ExtractTextPlugin ...

new ExtractTextPlugin({ 
    filename: '[name].properties', 
    allChunks: true, 
}), 
相關問題