0

I have a webpack project 3 and I want to run it on my local system.

Here is my webpack config file and the package.json

{
  "private": true,
  "name": "XXx",
  "version": "Xxx",
  "description": "X",
  "main": "index.js",
  "dependencies": {
    "babel": "^6.23.0",
    "css-loader": "^0.28.8",
    "extract-text-webpack-plugin": "^3.0.2",
    "findandreplacedomtext": "^0.4.6",
    "raw-loader": "^0.5.1",
    "style-loader": "^0.19.1",
    "text-loader": "0.0.1"
  },
  "devDependencies": {
    "nodemon": "^1.19.4",
    "sass": "^1.58.0",
    "uglifyjs-webpack-plugin": "^1.1.6",
    "webpack": "^3.10.0"
  },
  "scripts": {
    "min.js": "make min.js",
    "min.css": "make min.css",
    "serve": "webpack"
  },
  "author": "",
  "license": "ISC"
}

Makefile

const UglifyJs = require('uglifyjs-webpack-plugin')
const isWatching = process.argv[2] === '-w'

const plugins = [
  function() {
    this.plugin('watch-run', function(watching, callback) {
      console.log('Begin compile at ' + new Date())
      callback()
    })
  }
]

if (!isWatching) {
  plugins.unshift(
    new UglifyJs({
      extractComments: false,
      sourceMap: true,
    })
  )
}

module.exports = {
  entry: {
    'bundle': './js/bundle.js'
  },
  devtool: isWatching ? 'source-map' : false,
  output: {
    path: `${__dirname}/js`,
    filename: '[name].min.js',
    libraryTarget: 'umd',
  },
  module: {
    rules: [
      {
        test: /\.html$/,
        use: {
          loader: 'raw-loader',
        }
      },
      {
        test: /\.s?css$/,
        use: [
          {
            loader: "css-loader",
            options: {
              url: false, // do not bundle images
            },
          },
          {loader: "sass-loader"},
        ],
      }
    ]
  },
  plugins,
}

There is a makefile but I dont think this is required for this problem.

I have tried

webpack -p , webpack -w , and webpack .

webpack -p is giving an error : ERROR in bundle.min.js from UglifyJs Unexpected token: punc ({) [bundle.min.js:1,976]

while webpack -w works fine I am unable to find any url for the website.

the last command runs and ends.

shrey
  • 1
  • 2

0 Answers0