不排除node_modules

时间:2018-07-31 19:52:08

标签: node.js webpack node-modules

data6<-fread("https://data.colorado.gov/resource/8jg4-bud5.csv", na.strings = c("", "NA"))版本= 3.1.0

package.json

webpack-cli

webpack.config.js

   {
  "name": "zinuku",
  "version": "1.0.0",
  "description": "",
  "main": "index.jsx",
  "scripts": {
    "build": "webpack-cli",
    "start": "webpack-dev-server"
  },
  "dependencies": {
    "react": "^16.4.1",
    "react-dom": "^16.4.1"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-preset-react": "^6.24.1",
    "html-webpack-plugin": "^3.2.0",
    "webpack": "^4.16.3",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.5",
    "webpack-node-externals": "^1.7.2"
  }
}

重击(显示node_modules也已构建!)

npm运行开始

const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');

var HTMLWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
    template: __dirname + '/app/index.html',
    filename: 'index.html',
    inject: 'body'
});


module.exports = {
    entry: __dirname + '/app/index.jsx',
    mode: 'development',
    target: 'node', // in order too ignore built-in modules like path, fs, etc.
    externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.jsx$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            }
        ]
    },
    output: {
        filename: 'transformed.js',
        path:  __dirname + '/build'
    },
    plugins: [HTMLWebpackPluginConfig]
};

0 个答案:

没有答案