Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sass/css webpack loader #4

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@
},
"homepage": "https://github.com/plangrid/react-file-viewer#readme",
"devDependencies": {
"autoprefixer": "^7.1.0",
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.1",
"html-webpack-plugin": "^2.28.0",
"node-sass": "^4.5.3",
"postcss-loader": "^2.0.5",
"sass-loader": "^6.0.5",
"style-loader": "^0.17.0",
"webpack": "^2.5.1",
"webpack-dev-server": "^2.4.5"
},
Expand Down
3 changes: 2 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';
import FileViewer from './components/file-viewer.jsx';
import "styles/main.scss";

ReactDOM.render(
<FileViewer fileType="csv"
filePath="http://spatialkeydocs.s3.amazonaws.com/FL_insurance_sample.csv"/>,
document.getElementById('app')
);
);
3 changes: 3 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
color: red;
}
30 changes: 30 additions & 0 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require("path");
const webpack = require("webpack");
const autoprefixer = require("autoprefixer");

const HtmlWebpackPlugin = require("html-webpack-plugin");

Expand Down Expand Up @@ -34,6 +35,35 @@ module.exports = {
cacheDirectory: true,
},
},
{
test: /\.(css|scss)$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: () => [
autoprefixer({
browsers: [
">1%",
"last 4 versions",
"not ie < 9",
],
}),
],
},
},
{
loader: "sass-loader",
},
],
},
],
},

Expand Down
46 changes: 41 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const webpack = require('webpack');
const path = require('path');
const autoprefixer = require("autoprefixer");

var BUILD_DIR = path.resolve(__dirname, './dist');
var APP_DIR = path.resolve(__dirname, './src');
Expand All @@ -11,15 +12,50 @@ var config = {
filename: 'app.js'
},
resolve: {
modules: [path.resolve(__dirname, "./src"), "node_modules"],
extensions: ['.js', '.jsx', '.json'],
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.html$/, loader: "file?name=[name].[ext]" },
rules: [
{
test: /\.(js|jsx)$/,
include: path.resolve(__dirname, "./src"),
loader: "babel-loader",
options: {
cacheDirectory: true,
},
},
{
test: /\.(css|scss)$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: () => [
autoprefixer({
browsers: [
">1%",
"last 4 versions",
"not ie < 9",
],
}),
],
},
},
{
loader: "sass-loader",
},
],
},
],
},
};

module.exports = config;
module.exports = config;