| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- const webpack = require('webpack');
- const CopyWebpackPlugin = require('copy-webpack-plugin');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const MiniCssExtractPlugin = require('mini-css-extract-plugin')
- const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
- const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
- const path = require('path');
- function resolvePath(dir) {
- return path.join(__dirname, '..', dir);
- }
- module.exports = {
- mode: 'production',
- entry: [
- './src/app.js'
- ],
- output: {
- path: resolvePath('www'),
- filename: 'app.js',
- publicPath: ''
- },
- devServer: {
- hot: true,
- open: true,
- compress: true,
- contentBase: '/www/',
- watchOptions: {
- poll: true
- }
- },
- module: {
- rules: [
- {
- test: /\.js$/,
- use: 'babel-loader',
- include: [
- resolvePath('src'),
- resolvePath('node_modules/framework7'),
- resolvePath('node_modules/template7'),
- resolvePath('node_modules/dom7'),
- resolvePath('node_modules/ssr-window'),
- ],
- },
- {
- test: /\.f7.html$/,
- use: [
- 'babel-loader',
- {
- loader: 'framework7-component-loader',
- options: {
- helpersPath: './src/template7-helpers-list.js'
- }
- }
- ],
- },
- {
- test: /\.css$/,
- use: [
- MiniCssExtractPlugin.loader,
- 'css-loader',
- ],
- },
- {
- test: /\.styl(us)?$/,
- use: [
- MiniCssExtractPlugin.loader,
- 'css-loader',
- 'stylus-loader',
- ],
- },
- {
- test: /\.less$/,
- use: [
- MiniCssExtractPlugin.loader,
- 'css-loader',
- 'less-loader',
- ],
- },
- {
- test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: 'images/[name].[hash:7].[ext]'
- }
- },
- {
- test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: 'media/[name].[hash:7].[ext]'
- }
- },
- {
- test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: 'fonts/[name].[hash:7].[ext]'
- }
- }
- ]
- },
- plugins: [
- new webpack.DefinePlugin({
- 'process.env': JSON.stringify('production'),
- }),
- new UglifyJsPlugin({
- uglifyOptions: {
- compress: {
- }
- },
- sourceMap: true,
- parallel: true
- }),
- new OptimizeCSSPlugin({
- cssProcessorOptions: {
- safe: true,
- map: { inline: false }
- }
- }),
- new webpack.HotModuleReplacementPlugin(),
- new webpack.NamedModulesPlugin(),
- new HtmlWebpackPlugin({
- filename: './index.html',
- template: './src/index.html',
- inject: true,
- minify: {
- removeComments: true,
- collapseWhitespace: true,
- removeAttributeQuotes: true,
- },
- }),
- new webpack.HashedModuleIdsPlugin(),
- new webpack.optimize.ModuleConcatenationPlugin(),
- new MiniCssExtractPlugin({
- filename: 'app.css'
- }),
- new CopyWebpackPlugin([{
- from: resolvePath('static'),
- to: resolvePath('www/static'),
- }]),
- ]
- }
|