const path = require("path");
const PATHS = {
app: path.join(__dirname, "app"),
build: path.join(__dirname, "build")
};
const config = {
entry: PATHS.app + "/js/application.js",
output: {
path: PATHS.build,
filename: "js/[name].js"
},
context: path.resolve(__dirname, 'app'),
.....
const postcssImport = require("postcss-import");
const cssnext = require("cssnext");
const postcssInlineComment = require("postcss-inline-comment");
const postcssNested = require("postcss-nested");
const postcssColourFunctions = require("postcss-colour-functions");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
module.exports = function() {
return {
plugins: [
postcssImport,
postcssInlineComment,
cssnext,
postcssNested,
postcssColourFunctions,
autoprefixer({
browsers: ["last 2 versions"]
}),
cssnano
]
};
};
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const env = process.env.NODE_ENV || "development";
const PATHS = {
app: path.join(__dirname, "app"),
build: path.join(__dirname, "build")
};
const config = {
entry: PATHS.app + "/js/application.js",
output: {
path: PATHS.build,
filename: "js/[name].js"
},
module: {
rules: [
{
test: /\.pug$/,
loader: "pug-loader",
options: {
pretty: true
}
},
{
test: /\.js$/,
exclude: [/node_modules/],
use: [{
loader:"babel-loader",
options: { presets: ["es2015"] }
}]
},
{
test: /\.(jpg|png|svg)$/,
loader: "file-loader",
options: {
name: "img/[name].[ext]"
}
},
{
test: /\.json$/,
loader: "json-loader"
}
]
},
devtool: env === "development" ? "eval-source-map" : "",
plugins: [
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(env)
}),
new HtmlWebpackPlugin({
filename: "index.html",
template: PATHS.app + "/templates/layouts/layout.pug"
}),
new webpack.ProvidePlugin({
$: "jquery",
JQuery: "jquery"
}),
new webpack.optimize.CommonsChunkPlugin({
name: "common"
}),
]
};
if (env === "production") {
config.module.rules.push({
test: /\.css$/,
use: ExtractTextPlugin.extract({
publicPath: "./build",
fallback: "style-loader",
use: [
{
loader: "css-loader",
query: {
modules: true,
importLoaders: 1
}
},
{
loader: "postcss-loader"
}
],
}),
});
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new ExtractTextPlugin({
filename: "./css/[name].css",
allChunks: true
})
);
}
else {
config.module.rules.push({
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: { importLoaders: 1 }
},
{
loader: "postcss-loader"
}
]
});
config.devServer = {
stats: "errors-only",
port: 9000
};
}
module.exports = config;
@import "core/config" ....
ERROR in ./~/css-loader?{"modules":true,"importLoaders":1}!./~/postcss-loader/lib?{"config":{"path":"E://projects//webpack-project//postcss.con
fig.js"}}!./app/css/styles.css
Module build failed: Error: Failed to find 'core/config'
in [
E:\projects\webpack-project\app\css
]
at E:\projects\webpack-project\node_modules\postcss-import\lib\resolve-id.js:48:11