В структуре файлов есть:
dist
src
-static
-file.txt
Конфигурация webpack
const webpack = require('webpack');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const merge = require('webpack-merge');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const isProduction = process.env.NODE_ENV === 'production';
const path = require('path');
let config = {
mode: isProduction ? 'production' : 'development',
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
]
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: file => /node_modules/.test(file) && !/\.vue\.js/.test(file),
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: 'images/[name].[hash:8].[ext]',
publicPath: 'dist/',
},
},
},
{
test: /\.(eot|ttf|woff|woff2)$/,
loader: 'url-loader',
options: {
limit: 10000,
name: '[name].[hash:8].[ext]',
publicPath: 'dist/',
},
}
],
},
plugins: [
new VueLoaderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new rawLoader()
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"), // After this configuration @ can point to the src directory
},
}
};
if (isProduction) {
config = merge(config, {
optimization: {
minimize: true,
minimizer: [new OptimizeCSSAssetsPlugin(), new TerserPlugin()],
},
});
}
module.exports = config;