2018-05-17 20:08:34 +00:00
|
|
|
|
|
|
|
import webpack from 'webpack';
|
|
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
|
|
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
|
|
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
2018-09-04 15:10:52 +00:00
|
|
|
import { SRC, BUILD, PUBLIC } from './constants';
|
2018-05-17 20:08:34 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: 'production',
|
|
|
|
entry: {
|
2018-08-27 15:15:22 +00:00
|
|
|
index: [`${SRC}index.js`],
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
output: {
|
2018-08-27 15:15:22 +00:00
|
|
|
filename: '[name].[hash].js',
|
2018-05-17 20:08:34 +00:00
|
|
|
path: BUILD,
|
|
|
|
publicPath: './',
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2018-07-30 10:47:37 +00:00
|
|
|
use: ['babel-loader'],
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: [
|
2018-05-18 16:23:46 +00:00
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
2018-07-30 10:47:37 +00:00
|
|
|
options: { publicPath: '../' },
|
2018-05-18 16:23:46 +00:00
|
|
|
},
|
2018-07-30 10:47:37 +00:00
|
|
|
{
|
2018-05-17 20:08:34 +00:00
|
|
|
loader: 'css-loader',
|
2018-07-30 10:47:37 +00:00
|
|
|
options: {
|
2018-05-18 16:23:46 +00:00
|
|
|
minimize: false,
|
2018-07-30 10:47:37 +00:00
|
|
|
},
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
2018-07-30 10:47:37 +00:00
|
|
|
{
|
2018-05-17 20:08:34 +00:00
|
|
|
loader: 'less-loader',
|
2018-07-30 10:47:37 +00:00
|
|
|
options: {
|
2018-05-18 16:23:46 +00:00
|
|
|
minimize: false,
|
2018-07-30 10:47:37 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|gif|jpg)$/,
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
loader: 'file-loader',
|
|
|
|
query: {
|
2018-05-18 16:23:46 +00:00
|
|
|
outputPath: './images',
|
2018-07-30 10:47:37 +00:00
|
|
|
name: '[name].[hash].[ext]',
|
|
|
|
},
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(ttf|eot|svg|woff|woff2)$/,
|
|
|
|
loader: 'file-loader',
|
|
|
|
query: {
|
2018-05-18 16:23:46 +00:00
|
|
|
outputPath: './fonts',
|
|
|
|
name: '[name].[hash].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'javascript/auto',
|
|
|
|
test: /\.json/,
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
loader: 'file-loader',
|
|
|
|
query: {
|
|
|
|
outputPath: './data',
|
|
|
|
name: '[name].[hash].[ext]',
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-30 10:47:37 +00:00
|
|
|
],
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
2018-09-04 15:10:52 +00:00
|
|
|
alias: {
|
|
|
|
public: PUBLIC,
|
|
|
|
},
|
2018-05-17 20:08:34 +00:00
|
|
|
modules: [SRC, 'node_modules'],
|
|
|
|
},
|
|
|
|
performance: {
|
2018-07-30 10:47:37 +00:00
|
|
|
hints: false,
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'css/[name].[hash].css',
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
chunks: ['index'],
|
|
|
|
template: `${SRC}index.html`,
|
|
|
|
filename: 'index.html',
|
2018-07-30 10:47:37 +00:00
|
|
|
inject: true,
|
2018-09-04 16:17:09 +00:00
|
|
|
favicon: `${SRC}images/favicon.ico`,
|
2018-05-17 20:08:34 +00:00
|
|
|
}),
|
|
|
|
new CopyWebpackPlugin([
|
2018-09-04 15:10:52 +00:00
|
|
|
{ from: `${PUBLIC}`, to: './' },
|
2018-05-17 20:08:34 +00:00
|
|
|
]),
|
|
|
|
new webpack.optimize.OccurrenceOrderPlugin(),
|
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
|
|
|
new webpack.NamedModulesPlugin(),
|
2018-07-30 10:47:37 +00:00
|
|
|
],
|
|
|
|
};
|