我在Cordova项目中通过npm安装了font-awesome-webpack.我使用webpack创建一个bundle.js文件到我的/ www-folder.要使字体工作,我还必须将font-awesome-files构建到此文件夹.我的wepack.config.js:
module.exports = {
devtool: 'source-map',
entry: {
app: ["./src/main.jsx"]
},
output: {
path: path.resolve(__dirname, "dist/cwebphone/www"),
publicPath: "http://localhost:8088/",
filename: "bundle.js"
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
module: {
loaders: [{
test: /\.js?$/,
loaders: ['react-hot', 'babel'],
exclude: /node_modules/,
include: __dirname
},
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.png$/, loader: "url-loader", query: { mimetype: "image/png"}},
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.(otf|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },
{
test: /\.jsx$/,
loaders: ['react-hot', 'babel'],
exclude: /node_modules/,
include: __dirname
}
]
}
};
在我的main.jsx中,我需要Font-awesome-webpack:
require("font-awesome-webpack!../node_modules/font-awesome-webpack/font-awesome.config.js");
构建的文件是.woff,.woff2,.svg,.eot和.ttf文件.font-awesome-folder还包含一个未构建的otf文件.有谁知道我错过了什么让这个工作?