4
我有一個名爲「LICENSE」的外部許可證文件和webpack.BannerPlugin。我可以將LICENSE的內容複製/粘貼到BannerPlugin;的字符串字段中。但它很大,很醜。從Webpack中的外部文件添加許可證標題
這將是更清潔的,如果我可以使用文本或生裝載機代替:當我嘗試這個,我得到"Error: Cannot find module 'raw!./LICENSE'"
,大概是因爲要求沒有配置足夠早BannerPlugin(require("raw!./LICENSE"))
。有沒有辦法做我想要的?我搜索了很多,並繼續回來把整個許可證字符串放入BannerPlugin conf。
編輯:加入我的基本webpack.config文件:
// webpack.config.js
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: "./dev/main.js",
devtools: "source-map",
output: {
path: "./bin",
filename: "[name].js"
},
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
}
]
},
plugins: [
new ExtractTextPlugin("bundle.css"),
new webpack.BannerPlugin("Copyright 2016 Adam Mooz. Released under the MIT license"),
new webpack.optimize.UglifyJsPlugin({
minimize: true
}),
new HtmlWebpackPlugin({
title: "Grocery List",
hash: true
})
]
};
,你可以把你的WebPack配置文件嗎? – jkris
當然,對不起。我剛剛更新了主要問題。 –
所以你試圖在配置文件中require(「raw!./ LICENSE」)? – jkris