copy-webpack-plugin & ignore folder
copy-webpack-plugin & ignore folder
https://github.com/webpack-contrib/copy-webpack-plugin#ignore
ignore bug
not ignore folders
copy-webpack-plugin ignore folder
https://github.com/webpack-contrib/copy-webpack-plugin/issues/54
OK
ignore
folder
&any thing in the folder
==="libs/**/*"
ignore some
.extension
files ===["*.md", "*.js", "*.css" ]
// ignore folder & any thing in the folder === "libs/**/*"
// ignore some .extension files === ["*.md", "*.js", "*.css" ]
new CopyWebpackPlugin([
{
from: "./src/backend-system/",
to: "../",
ignore: ["*.md", "*.js", "*.css", "others/*", "libs/**/*"]
},
{
from: "./src/backend-system/index.css",
to: "./css/"
}
]),
ignore bug
not ignore folders
copy-webpack-plugin ignore folder
https://github.com/webpack-contrib/copy-webpack-plugin/issues/54
OK
ignore
folder
&any thing in the folder
==="libs/**/*"
ignore some
.extension
files ===["*.md", "*.js", "*.css" ]
// ignore folder & any thing in the folder === "libs/**/*"
// ignore some .extension files === ["*.md", "*.js", "*.css" ]
new CopyWebpackPlugin([
{
from: "./src/backend-system/",
to: "../",
ignore: ["*.md", "*.js", "*.css", "others/*", "libs/**/*"]
},
{
from: "./src/backend-system/index.css",
to: "./css/"
}
]),
bad
perfect
new CopyWebpackPlugin([
// {
// from: "./src/imgs",
// to: "./imgs/",
// ignore: ["*.md"]
// },
// {
// from: "./src/templates",
// to: "./templates/",
// ignore: ["*.md"]
// },
// {
// from: "./favicon.ico",
// to: "./"
// },
// {
// from: "./src/backend-system/**/*.html",
// to: "../",
// ignore: ["others/*", "libs/**/*"]
// },
{
from: "./src/backend-system/",
to: "../",
ignore: ["*.png", "*.md", "*.js", "*.css", "others/*", "libs/**/*"]
},
{
from: "./src/backend-system/layui.css",
to: "../css/"
},
{
from: "./src/backend-system/index.css",
to: "../css/"
},
{
from: "./src/backend-system/icon.png",
to: "../css/"
}
]),
webpack.config.js
"use strict";
/**
* @Created by xgqfrms on 2016/1/26.
* @version 1.0.0 created
* @description APDP\webpack.config.js
* @author xgqfrms
*
* @license MIT
* @copyright xgqfrms 2016-forever || 2018-present
*
*/
const path = require("path");
const webpack = require("webpack");
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
require("babel-polyfill");
const extractSCSS = new ExtractTextPlugin({
filename: (getPath) => {
// relative path
return getPath("../css/[name].min.css?[hash:8]");
},
// allChunks: true,
});
// process.env.NODE_ENV = `production`;
process.env.NODE_ENV = `development`;
if (process.env.NODE_ENV !== "production") {
console.log("😃, Looks like we are in development mode!");
}else{
console.log("Tada, 🎉, we are in production mode!");
}
const BASE_URI = {
index: `./index`,
MODULES: `./src/backend-system`,
FES: `./src/frontend-system`,
BS: `./src/backend-system/select-tree`,
COMPONENTS: `./table-components`,
TEST: `./table-components/test`,
app: "select-tree",
};
const modulesArray = [
"index",// index & "babel-polyfill",
"urls",
"layui",// just for minify css
"select-tree",
"project-table",
"project-form",
"svn-table",
"svn-form",
"service-table",
"service-form",
];
const fesArray = [
// "index",// index & "babel-polyfill"
"project-table",
"project-form",
"server-table",
"server-form",
"logs-tree",
"config-tree",
];
const tableComponents = [
"basic-table",
"fixed-header-table",
"fixed-column-table",
"fixed-row-table",
"fixed-header-column-table"
// "fixed-rows-table",
// "fixed-cols-table",
];
const tableTest = [
"basic-table.spec",
"fixed-header-table.spec",
"fixed-column-table.spec",
"fixed-row-table.spec",
"fixed-header-column-table.spec",
// "fixed-rows-table.spec",
// "fixed-cols-table.spec",
];
let entryObject = {};
// entryObject["babel-polyfill"] = "babel-polyfill";
// entryObject["select-tree"] = ["babel-polyfill", `${BASE_URI.BS}`];
// entryObject[`${BASE_URI.app}`] = ["babel-polyfill", `${BASE_URI.BS}`];
modulesArray.forEach(
(item, i) => {
// entryObject[item] = ["babel-polyfill", `${BASE_URI.MODULES}/${item}`];
// only entry & import "babel-polyfill";
entryObject[item] = `${BASE_URI.MODULES}/${item}`;
}
);
// fesArray.forEach(
// (item, i) => {
// entryObject[item] = `${BASE_URI.FES}/${item}`;
// }
// );
// tableComponents.forEach(
// (item, i) => {
// entryObject[item] = `${BASE_URI.COMPONENTS}/${item}`;
// }
// );
// tableTest.forEach(
// (item, i) => {
// entryObject[item] = `${BASE_URI.TEST}/${item}`;
// }
// );
module.exports = {
entry: Object.assign({}, entryObject),
output: {
path: path.resolve(__dirname, "build/js/"),
filename: "[name].min.js",
},
resolve: {
extensions: [".js",".css"]
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader",
},
{
test: /\.((s*)css|sass)$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: "css-loader",
options: {
url: false,
// url: true,
minimize: true,
sourceMap: true,
modules: true,
importLoaders: 1,
localIdentName: "[local]",
}
},
{
loader: "sass-loader",
options: {
sourceMap: true,
}
}
],
fallback: "style-loader",
}),
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: "url-loader",
options: {
limit: 10000
}
},
]
},
devtool: "source-map",
plugins: [
new UglifyJSPlugin({
sourceMap: true,
// extractComments: false,
extractComments: true,
parallel: 4,
cache: true,
}),
extractSCSS,
new CopyWebpackPlugin([
// {
// from: "./src/imgs",
// to: "./imgs/",
// ignore: ["*.md"]
// },
// {
// from: "./src/templates",
// to: "./templates/",
// ignore: ["*.md"]
// },
// {
// from: "./favicon.ico",
// to: "./"
// },
// {
// from: "./src/backend-system/**/*.html",
// to: "../",
// ignore: ["others/*", "libs/**/*"]
// },
{
from: "./src/backend-system/",
to: "../",
ignore: ["*.png", "*.md", "*.js", "*.css", "others/*", "libs/**/*"]
},
// {
// from: "./src/backend-system/layui.css",
// to: "../css/"
// },
// {
// from: "./src/backend-system/index.css",
// to: "../css/"
// },
{
from: "./src/backend-system/icon.png",
to: "../css/"
}
]),
],
// devServer: {
// contentBase: path.resolve(__dirname, `dist`),
// host: `http://10.1.5.202`,
// compress: true,
// port: 8080
// },
};
refs
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/9144717.html
未经授权禁止转载,违者必究!