Slate: Question: How do i use this with webpack ?

Created on 25 Jan 2017  路  6Comments  路  Source: ianstormtaylor/slate

While trying to integrate it with webpack, i get the following error:

ERROR in ./~/slate/~/cheerio/~/entities/maps/decode.json
Module parse failed: {path}\node_modules\slate\node_modules\cheerio\node_modules\entities\maps\decode.json Unexpected token (1:4)
You may need an appropriate loader to handle this file type.

If I include the json-loader loader, then i start getting this error:

Module build failed: SyntaxError: Unexpected token i
    at Object.parse (native)
    at Object.module.exports ({path}\node_modules\json-loader\index.js:7:48)
 @ multi path

Am I doing something wrong here ?

All 6 comments

I believe this has something to do with this issue

solved it

@eelsweb Ran into this as well (your first mentioned problem) and I do have the json-loader. Can you share your solution/your webpack config?

Could someone share webpack config please! I stuck with Module build failed: SyntaxError: Unexpected token

hey @oyeanuj @pigareva .. sorry .. i no longer remember how exactly i solved this.. perhaps if you shared your webpack.config .. i might remember what i changes.. this is what the module key should look like (i hope :) )

module: {
    loaders: [{
        test: /\.js?/,
        include: srcDir,
        loaders: ['babel-loader']
    }, {
        test: /\.json$/,
        loaders: ['json-loader']
    }, {
        test: /\.scss/,
        loaders: ['style-loader', 'css-loader', 'sass-loader']
    }, {
        test: /\.css/,
        loaders: ['style-loader', 'css-loader']
    }]
}

@eelsweb thanks a lot! I solved it with a proper .babelrc, which is in my case
{ "presets": [ "react", ["env", { "targets": { "browsers": [ "last 2 Chrome versions", "last 2 Firefox versions", "last 2 Edge versions" ] } }], "stage-0" ] }
"stage-0" preset looks to be very important.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ianstormtaylor picture ianstormtaylor  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

adrianclay picture adrianclay  路  3Comments

varoot picture varoot  路  3Comments