Discussions

Ask a Question
Back to All

How to process css import from npm in spike app

down vote
favorite
I'm trying to include purecss from npm into my spike app, which throws the loader error, can someone let me know the way to import css file from npm

index.js:

import purecss from 'purecss'

ERROR:

{ ModuleParseError: Module parse failed: /Users/loganathans/projects/spike-app/node_modules/purecss/build/pure-min.css Unexpected token (11:76)

app.js:

const htmlStandards = require('reshape-standard')
const cssStandards = require('spike-css-standards')
const jsStandards = require('spike-js-standards')
const pageId = require('spike-page-id')
const path = require('path')
const env = process.env.NODE_ENV

module.exports = {
devtool: 'source-map',
matchers: { html: '(**/).sgr', css: '(**/).css' },
ignore: ['/layout.sgr', '/_', '**/.', 'readme.md', 'yarn.lock'],
reshape: htmlStandards({
locals: (ctx) => { return { pageId: pageId(ctx), foo: 'bar' } },
minify: env === 'production'
}),

postcss: cssStandards({
parser: false,
path: path.join(__dirname, './assets/css/css_modules'),
minify: env === 'production',
warnForDuplicates: env !== 'production'
}),
babel: jsStandards()
}

So in this case, as the error mentions, you are trying to import a css file into a javascript file and it's unable to figure out how to deal with this. I would recommend importing the css into your css, rather than your javascript. To do this, you can use @import inside your css file 😁

ο»Ώ