Code Monkey home page Code Monkey logo

webpack-lib-env's Introduction

webpack ---js模块开发环境

20190520 -- 支持es6+环境

webpack.config.js

const path = require('path');
const cleanWebpackPlugin = require('clean-webpack-plugin');
const clean = new cleanWebpackPlugin();

const webpackConfig = (env, argv) => {

  return {
    entry: path.resolve(__dirname, 'src/index.js'),
    output: {
      filename: '[name].[hash:8].js',
      path: path.resolve(__dirname, 'dist'),
      library: 'ChartLib',
      // "var", "assign", "this", "window", "global", "commonjs",
      // "commonjs2", "commonjs-module", "amd", "umd", "umd2", "jsonp"
      libraryTarget: 'umd',
    },
    devtool: argv.mode === 'development' ? "source-map" : 'none',
    module: {
      rules: [
        {
          test: /\.css$/,
          use: ['style-loader', 'css-loader'],
        },
        {
          test: /\.m?js$/,
          exclude: /(node_modules|bower_components)/,
          use: {
            loader: 'babel-loader',
          }
        }
      ]
    },
    plugins: [
      clean,
    ]
  }
};

module.exports = webpackConfig;

.babelrc

{
  "presets": [
    "@babel/preset-env"
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties"
  ],
  "sourceType":"unambiguous"
}

webpack-lib-env's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.