У меня есть следующее:
<Target Name="OnBuild" BeforeTargets="Build" Condition="'$(Configuration)' == 'Debug'">
<Exec WorkingDirectory="app" Command="npm install" />
<Exec WorkingDirectory="app" Command="npm run build" />
</Target>
Команда «npm run build» создает папку «client / dist».
Как скопировать папку и ее содержимое в "wwwroot" с помощью задачи MSBuild?
Я использую ASP.NET Core 2.2 ...
Webpack.config
const path = require('path');
const environment = process.env.NODE_ENV;
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
plugins: [
new MiniCssExtractPlugin({
filename: 'main.min.css',
}),
new CopyPlugin([
{ from: './assets', to: './assets' }
])
],
resolve: {
extensions: ['.js'],
},
entry: path.resolve(__dirname, 'src/app/index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.min.js'
},
optimization: {
minimizer: [
new MiniCssExtractPlugin({}),
new OptimizeCSSAssetsPlugin({}),
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false
})
]
},
module: {
rules: [
{
test: /\.less$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader', 'less-loader' ]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [ 'file-loader' ]
},
{
test: /\.(otf|eot|ttf|woff|woff2)$/,
use: [ 'file-loader' ]
}
]
},
watch: true
};