You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

121 lines
2.8 KiB

const path = require('path');
const autoprefixer = require('autoprefixer');
const TerserPlugin = require('terser-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const Chunks2JsonPlugin = require('chunks-2-json-webpack-plugin');
// const OutputPath = process.env.ENV_MODE
module.exports = [{
mode: "development", // "production" | "development" | "none"
entry: {
main: ['./src/ts/index.ts', './src/scss/index.scss']
},
output: {
path: path.resolve(__dirname, './dist'),
filename: './js/bundle.js'
},
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, './dist'),
publicPath: '/',
port: 8080,
host: '0.0.0.0',
// proxy: {},
compress: true,
// historyApiFallback: true,
},
module: {
rules: [{
test: /\.(png|jpg|gif|svg)$/,
exclude: [
path.resolve(__dirname, './node_modules'),
],
use: {
loader: 'file-loader',
options: {
// name(file) {
// return './images/[name].[ext]';
// },
name: '../images/[name].[ext]'
// outputPath: './images',
},
},
},
{
test: /\.scss$/,
use: [{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'css-loader'
},
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer()]
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
includePaths: ['./node_modules']
},
}
},
]
},
{
test: /\.tsx?$/,
use: [{
loader: 'babel-loader',
query: {
presets: ['@babel/preset-typescript'],
},
}, ],
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
// optimization: {
// minimize: true,
// minimizer: [new TerserPlugin({
// sourceMap: false,
// })],
// },
plugins: [
new CopyPlugin([
{
from: './src/package.less',
to: './style.css',
toType: 'file',
},
{
from: './src/*.html',
to: './[name].[ext]',
toType: 'template',
},
{
from: './src/php/*.php',
to: './[name].[ext]',
toType: 'template',
}
]),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "./css/bundle.css",
// chunkFilename: "[id].css"
}),
new Chunks2JsonPlugin({
outputDir: 'dist/',
filename: 'manifest.json'
})
],
}];