1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- const webpack = require('webpack');
- const path = require('path');
- const merge = require('webpack-merge');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const autoprefixer = require('autoprefixer');
- const ExtractTextPlugin = require('extract-text-webpack-plugin');
- const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
- const rm = require('rimraf');
- const baseWebpackConfig = require('./webpack.config.js');
- const config = require('./config.js');
- const webpackConfig = merge(baseWebpackConfig, {
- entry: {
-
-
- main: [
-
-
- path.resolve(__dirname, '../src/main.pro.js')
- ],
- },
- output: {
- publicPath: config.prod.publicPath,
- path: config.prod.root,
- filename: path.posix.join(config.prod.subDirectory, 'js/[name].[contenthash:5].js'),
- chunkFilename: path.posix.join(config.prod.subDirectory, 'js/[name].[chunkhash:5].chunk.js'),
- },
- mode: 'production',
- module: {
- rules: [{
- test: /\.(css|scss)$/,
- use: ExtractTextPlugin.extract({
- use: [
- 'css-loader',
- {
- loader: 'postcss-loader',
- options: {
- plugins: function () {
- return [autoprefixer({ browsers: ["> 1%","last 2 versions","not ie <= 8"] })];
- }
- }
- },
- {
- loader: 'sass-loader',
- options: {
- includePaths: [path.resolve(__dirname, "../node_modules/compass-mixins/lib")]
- }
- }
- ],
- fallback: 'style-loader'
- })
- }]
- },
- plugins: [
-
- new ExtractTextPlugin({
- filename: path.posix.join(config.prod.subDirectory, 'css/[name].[chunkhash:5].css'),
-
- }),
-
- new OptimizeCSSPlugin(),
-
- new HtmlWebpackPlugin({
- template: path.resolve(__dirname, '../src/index.html'),
- filename: 'index.html',
- inject: true,
-
-
-
-
-
-
-
- }),
-
- ]
- });
- rm(path.join(config.prod.root, config.prod.subDirectory), err => {
- if (err) throw err;
- webpack(webpackConfig, function (err, stats) {
- if (err) throw err;
- process.stdout.write(stats.toString({
- colors: true,
- modules: false,
- children: false,
- chunks: false,
- chunkModules: false
- }) + '\n\n');
- console.log(' Build complete.\n');
- });
- });
|