1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- const webpack = require('webpack');
- const path = require('path');
- const config = require('./config.js');
- const rm = require('rimraf');
- const fs = require('fs')
- const nodeModules = {}
- fs.readdirSync('node_modules')
- .filter(function (x) {
- return [ '.bin' ].indexOf(x) === -1
- })
- .forEach(function (mod) {
- nodeModules[ mod ] = 'commonjs ' + mod
- })
- const webpackConfig = {
- mode: 'production',
- target: 'node',
- node: {
- __filename: true,
- __dirname: true,
- },
- externals: nodeModules,
- entry: {
- app: [
-
-
- path.resolve(__dirname, '../app.js')
- ],
- },
- output: {
- publicPath: config.prod.publicPath,
- path: config.prod.root,
- filename: '[name].js',
- },
- resolve: {
- extensions: ['.js'],
-
-
-
-
- },
- module: {
- rules: [{
- test: /\.(js|jsx)$/,
- loader: 'babel-loader',
- include: [path.resolve(__dirname, '../src'), path.resolve(__dirname, '../server')],
- }, {
- test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- }
- }, {
- test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- }
- }, {
- test: /\.(css|scss)$/,
- use: [
- 'css-loader/locals',
- 'sass-loader',
- ]
- }]
- },
-
- };
- rm(path.join(config.prod.root, 'app.js'), 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');
- });
- });
|