Saturday, 6 May 2017

Cannot find module "bundle.js". Work only with server

I have a strange problem.... (Please, ignore my bad english :v)

I'm making app using HTML/CSS and js with jQuerry. I'm using webpack too. I used webpack-dev-server command since today - everything was working perfect. I wanted to generate single file - "bundle.js" without using server, cause i wanted to open app at another pc, without webpack.

That's how game looks like when it works

When i changed config in package.json from: "start": "webpack-dev-server ./src/scrable.js" To: "start": "webpack ./src/scrable.js ./bundle.js"

I haven't any errors in my CMD console, when i typed "npm start". But, when i open my index.html file i saw in "source" mode that i have one error, which means that browser 'Cannot find module "bundle.js"'. App is working, but not like it should - elements react for clicks, they're running some functions, but... just look at this:

That's how game looks like when it doesn't work

Do you have any ideas? This is my package.json file

{
  "name": "jstest_",
  "version": "1.0.0",
  "description": "",
  "main": "scrable.js",
  "scripts": {
    "start": "webpack ./src/scrable.js ./bundle.js"
      
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "css-loader": "^0.28.0",
    "style-loader": "^0.16.1",
    "webpack": "^2.3.2",
    "webpack-dev-server": "^2.4.2"
  }
}

And this is my webpack.config.js file

var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');

module.exports = {
  context: __dirname,
  devtool: debug ? "inline-sourcemap" : null,
  entry: "./src/scrable.js",
  output: {
    path: __dirname,
    filename: "bundle.js",
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
  module: {
    loaders: [
      { test: /\.css$/, loader: 'style-loader!css-loader' }
    ]
  }
};


via DarQ522

No comments:

Post a Comment