2020-08-09 11:21:29 +00:00
|
|
|
import * as path from "path";
|
|
|
|
import {Configuration} from "webpack";
|
|
|
|
import {CleanWebpackPlugin} from "clean-webpack-plugin";
|
2021-03-16 19:03:29 +00:00
|
|
|
import CopyWebpackPlugin from "copy-webpack-plugin";
|
2020-08-09 11:21:29 +00:00
|
|
|
|
|
|
|
export = {
|
|
|
|
entry: "./plugin/index.ts",
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
loader: "ts-loader"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, "package.json"),
|
|
|
|
to: path.join(__dirname, "dist")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, "package-lock.json"),
|
|
|
|
to: path.join(__dirname, "dist")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
],
|
|
|
|
|
|
|
|
mode: process.env.NODE_ENV === "development" ? "development" : "production",
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
extensions: [".ts", ".tsx", ".js"]
|
|
|
|
},
|
|
|
|
|
|
|
|
externals: [
|
|
|
|
(_, request, callback) => {
|
|
|
|
if(request.match(/^webpack(-sources)?(\/.*|$).*/))
|
|
|
|
callback(null, "commonjs " + request);
|
|
|
|
else
|
|
|
|
callback();
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"fs-extra": "commonjs fs-extra",
|
|
|
|
"path": "commonjs path"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
|
|
|
|
target: "node",
|
|
|
|
output: {
|
2021-03-16 18:20:57 +00:00
|
|
|
path: process.env.OUTPUT_PATH || path.resolve(__dirname, "dist"),
|
2020-08-09 11:21:29 +00:00
|
|
|
filename: "plugin.js",
|
|
|
|
|
|
|
|
libraryTarget: "umd",
|
|
|
|
library: "svg-sprite-plugin"
|
|
|
|
}
|
|
|
|
} as Configuration;
|