49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
const path = require('path');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
const ImageminPlugin = require('imagemin-webpack-plugin').default;
|
|
|
|
const config = {
|
|
entry: {
|
|
main: ['./assets/app.ts'],
|
|
},
|
|
output: {
|
|
path: path.resolve('./static/dist/'),
|
|
publicPath: "/dist/",
|
|
filename: "bundle.js",
|
|
chunkFilename: 'bundle.[chunkhash:8].js'
|
|
},
|
|
resolve: {
|
|
extensions: ['.tsx', '.ts', '.js'],
|
|
},
|
|
module: {
|
|
rules: [{
|
|
test: /\.s[ac]ss$/,
|
|
use: ["style-loader", "css-loader?sourceMap", "sass-loader?sourceMap"]
|
|
}, {
|
|
test: /\.css$/,
|
|
use: ["style-loader", "css-loader"]
|
|
}, {
|
|
test: /\.tsx?$/,
|
|
use: 'ts-loader',
|
|
exclude: /node_modules/
|
|
}, {
|
|
test: /\.(png|svg|jpg|gif)$/,
|
|
use: 'file-loader',
|
|
}, {
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
use: 'file-loader'
|
|
}]
|
|
},
|
|
plugins: [
|
|
new CopyWebpackPlugin({ patterns: [{ from: './assets/images/', to: '../images/' }] }),
|
|
new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i }),
|
|
]
|
|
};
|
|
|
|
module.exports = (env, argv) => {
|
|
if (argv.mode === 'development') {
|
|
config.devtool = 'inline-source-map';
|
|
}
|
|
|
|
return config;
|
|
}; |