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.
88 lines
2.4 KiB
88 lines
2.4 KiB
2 years ago
|
var path = require('path');
|
||
|
var webpack = require('webpack');
|
||
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
||
|
const config = require('./config.js');
|
||
|
|
||
|
const PATHS = {
|
||
|
app: path.join(__dirname, 'client/src'),
|
||
|
build: path.join(__dirname, 'client/build')
|
||
|
};
|
||
|
console.log(config);
|
||
|
module.exports = {
|
||
|
mode: "production",
|
||
|
entry: {
|
||
|
app: ["babel-polyfill", PATHS.app]
|
||
|
},
|
||
|
output: {
|
||
|
path: PATHS.build,
|
||
|
publicPath: '/build',
|
||
|
filename: '[name].[hash:5].js'
|
||
|
},
|
||
|
resolve: {
|
||
|
modules: [path.resolve(__dirname, 'client/src'), path.resolve(__dirname, 'node_modules')],
|
||
|
extensions: ['.js', '.jsx'],
|
||
|
alias: {
|
||
|
crypto: false,
|
||
|
$utils: path.resolve(__dirname, 'client/src/utils/'),
|
||
|
$components: path.resolve(__dirname, 'client/src/components/'),
|
||
|
}
|
||
|
},
|
||
|
plugins: [
|
||
|
new HtmlWebpackPlugin({
|
||
|
filename: '../index.html',
|
||
|
template: './client/index.ejs'
|
||
|
}),
|
||
|
new webpack.DefinePlugin({
|
||
|
'process.env.NODE_ENV': JSON.stringify('development'),
|
||
|
...(() => {
|
||
|
let nextParams = {}
|
||
|
for (let k in config.frontParams) {
|
||
|
nextParams[k] = JSON.stringify(config.frontParams[k])
|
||
|
}
|
||
|
return nextParams
|
||
|
})()
|
||
|
}),
|
||
|
],
|
||
|
optimization: {
|
||
|
splitChunks: {
|
||
|
cacheGroups: {
|
||
|
commons: {
|
||
|
test: /[\\/]node_modules[\\/]/,
|
||
|
name: "vendors",
|
||
|
chunks: "all"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
module: {
|
||
|
rules: [{
|
||
|
test: /\.css$/,
|
||
|
use: ['style-loader', {
|
||
|
loader: 'css-loader',
|
||
|
options: {
|
||
|
modules: true
|
||
|
}
|
||
|
}]
|
||
|
},
|
||
|
{
|
||
|
test: /\.less$/,
|
||
|
use: ['style-loader', 'css-loader',
|
||
|
{
|
||
|
loader: 'less-loader', options: {
|
||
|
lessOptions: {
|
||
|
javascriptEnabled: true
|
||
|
}
|
||
|
}
|
||
|
}]
|
||
|
},
|
||
|
{
|
||
|
test: /\.jsx?$/,
|
||
|
use: 'babel-loader',
|
||
|
include: [PATHS.app, path.resolve(__dirname, 'node_modules', '@peace')],
|
||
|
},{
|
||
|
test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/,
|
||
|
loader: "file-loader"
|
||
|
}]
|
||
|
}
|
||
|
};
|