cheton / browserify-css

A Browserify transform for bundling, rebasing, inlining, and minifying CSS files.
http://cheton.github.io/browserify-css/
MIT License
144 stars 22 forks source link

ParseError: Unexpected token ILLEGAL #45

Closed xErik closed 7 years ago

xErik commented 7 years ago

Hi,

this issues is probably not a browserify-css issue. But hopefully somebody else stumbled upon the same problem. I apologise in advance asking this here, but I am out of my wits.

Works

On the command line, this works fine:

browserify -g browserify-css src/index.js -o dist/bundle.js

Works Not

Using the same line inside package.json results in an error, indicating, that browserify-css is not processing the CSS files if started by npm run build:js

index.css

@import url("node_modules/bootstrap/dist/css/bootstrap.min.css");
^
ParseError: Unexpected token ILLEGAL

package.json

{
  "name": "bla",
  "version": "0.1.0",
  "description": "bla,
  "main": "src/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build:js": "browserify -g browserify-css src/index.js -o dist/bundle.min.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bootstrap": "^3.3.7",
    "jquery": "^3.1.1"
  },
  "devDependencies": {
    "browserify-css": "^0.9.2"
  }
}
cheton commented 7 years ago

Your package.json is missing a double-slash (") character at the end of the description field, but that's not the key point.

May I know which npm version you were running? I can run npm run build:js to create a JS bundle according to your setup:

package.json

{
  "name": "bla",
  "version": "0.1.0",
  "description": "bla",
  "main": "src/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build:js": "mkdir -p dist; browserify -g browserify-css src/index.js -o dist/bundle.min.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bootstrap": "^3.3.7",
    "jquery": "^3.1.1"
  },
  "devDependencies": {
    "browserify-css": "^0.9.2"
  }
}

src/index.js

require('./index.css');

src/index.css

@import url("node_modules/bootstrap/dist/css/bootstrap.min.css");
xErik commented 7 years ago

I am running: node v6.6.0 npm 3.10.7

And even downgraded to node 4.6.0

However, I created a fresh project and it suddenly works. I will hunt the problem down on my side.

Thanks, for confirming that this is not browserify-css issue. Sorry for the trouble.