我是webpack的新手,我需要帮助建立我的构建结构。我正在从命令行运行脚本,该脚本已成功编译,但是在主文件夹中仅创建了不必要的文件。
webpack.config.js:
const ExtractTextPlugin = require("extract-text-webpack-plugin"),
BrowserSyncPlugin = require("browser-sync-webpack-plugin"),
ImageMinPlugin = require('imagemin-webpack-plugin').default,
CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
devtool: "source-map",
entry: "./src/js/index.js",
output: {
filename: "./dist/js/bundle.min.js"
},
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader", "postcss-loader", "sass-loader"]
})
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: "babel-loader",
query: {
presets: ["es2015"]
}
},
{
test: /\.(jpe?g|png|woff|woff2|eot|ttf|svg)(\?[a-z0-9=.]+)?$/,
loader: "url-loader?limit=100000"
}
]
},
plugins: [
new ExtractTextPlugin("./dist/css/styles.css"),
new BrowserSyncPlugin({
proxy: "localhost/webpack-sass-build-structure", // Important: Change this to your path!
port: 8080,
files: ["**/*.php"],
ghostMode: {
clicks: false,
location: false,
forms: false,
scroll: false
},
injectChanges: true,
logFileChanges: true,
logLevel: "debug",
logPrefix: "wepback",
notify: true,
reloadDelay: 0
}),
new CopyWebpackPlugin([
{
from: 'src/images', to: 'dist/images', force: true
},
{
from: 'src/webfonts', to: 'dist/webfonts', force: true
}
]),
new ImageMinPlugin({ test: /\.(jpe?g|png|gif|svg)$/i }),
],
watch: true
};
我很确定此错误在这里。一切都很好,可以从src复制到dist文件夹,但是只有这些文件是通用的,我想阻止它。
new CopyWebpackPlugin([
{
from: 'src/images', to: 'dist/images', force: true
},
{
from: 'src/webfonts', to: 'dist/webfonts', force: true
}
]),
主文件夹中的文件示例:
418d54a4a9df0e7b3e28dc09e4cce808.ttf 686e245a4f1a9894d10a576655e932dd.woff 877baf6278a6f1506a07afd23b334f47.eot] [1]